Dockerfile 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # 使用指定基础镜像
  2. FROM docker.1ms.run/node:20.19.4
  3. # 设置软件源为清华大学镜像源
  4. RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main non-free contrib" > /etc/apt/sources.list && \
  5. echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main non-free contrib" >> /etc/apt/sources.list && \
  6. echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main non-free contrib" >> /etc/apt/sources.list && \
  7. echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main non-free contrib" >> /etc/apt/sources.list
  8. RUN apt update --fix-missing && \
  9. apt install -y curl wget
  10. # 安装 pnpm
  11. RUN npm install -g pnpm
  12. # 配置国内npm镜像
  13. RUN pnpm config set registry https://registry.npmmirror.com/
  14. RUN pnpm config set @jsr:registry https://npm.jsr.io
  15. # 添加PostgreSQL 17的官方仓库
  16. RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
  17. echo "deb http://apt.postgresql.org/pub/repos/apt/ bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list
  18. # 更新包列表并安装PostgreSQL 17客户端工具及其他常用工具(已添加jq)
  19. RUN apt update && \
  20. apt install -y \
  21. # PostgreSQL 17客户端工具
  22. postgresql-client-17
  23. # 确认版本
  24. RUN pg_dump --version
  25. # 设置工作目录
  26. WORKDIR /workspace
  27. # 复制根目录配置文件
  28. COPY package.json pnpm-lock.yaml .npmrc ./
  29. # 安装依赖
  30. RUN pnpm install --frozen-lockfile
  31. # 复制项目文件
  32. COPY . .
  33. # 构建 web 应用
  34. RUN pnpm run build
  35. # 暴露端口(根据实际需要调整)
  36. EXPOSE 8080
  37. # 启动命令
  38. CMD ["sh", "-c", "pnpm run start"]