Dockerfile 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. FROM node:20.19.4-bookworm
  2. # 使用官方 Debian APT 源
  3. RUN rm -rf /etc/apt/sources.list.d/* && \
  4. echo "deb http://mirrors.aliyun.com/debian/ bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
  5. echo "deb http://mirrors.aliyun.com/debian/ bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
  6. echo "deb http://mirrors.aliyun.com/debian/ bookworm-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
  7. echo "deb http://mirrors.aliyun.com/debian-security/ bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list
  8. # 完全禁用APT的GPG验证
  9. RUN echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/99allow-unauthenticated && \
  10. echo 'Acquire::AllowInsecureRepositories "true";' >> /etc/apt/apt.conf.d/99allow-unauthenticated && \
  11. echo 'Acquire::AllowDowngradeToInsecureRepositories "true";' >> /etc/apt/apt.conf.d/99allow-unauthenticated
  12. # 现在可以无验证更新和安装
  13. RUN apt update --fix-missing && \
  14. apt install -y curl wget
  15. # 安装 pnpm
  16. RUN npm install -g pnpm
  17. # 配置官方 npm 镜像
  18. RUN pnpm config set registry https://registry.npmjs.org/
  19. RUN pnpm config set @jsr:registry https://npm.jsr.io
  20. # 添加PostgreSQL 17的官方仓库
  21. RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
  22. echo "deb http://apt.postgresql.org/pub/repos/apt/ bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list
  23. # 更新包列表并安装PostgreSQL 17客户端工具
  24. RUN apt update && \
  25. apt install -y postgresql-client-17
  26. # 确认版本
  27. RUN pg_dump --version
  28. # 设置工作目录
  29. WORKDIR /workspace
  30. # 设置备份目录环境变量
  31. ENV BACKUP_DIR=/app/backups-prd/
  32. ENV LOG_DIR=/app/log-prd/
  33. # 设置MinIO自定义主机环境变量
  34. ENV MINIO_DIY_HOST=minio.yqingk.d8d.fun
  35. # 复制根目录配置文件
  36. COPY package.json pnpm-workspace.yaml pnpm-lock.yaml ./
  37. # 复制各项目 package.json
  38. COPY web/package.json ./web/
  39. COPY packages/ ./packages/
  40. # 安装依赖
  41. RUN pnpm install --frozen-lockfile
  42. # 复制项目文件
  43. COPY . .
  44. # 构建 web 应用
  45. RUN cd web && pnpm run build
  46. # 暴露端口(根据实际需要调整)
  47. EXPOSE 8080
  48. # 启动命令
  49. CMD ["sh", "-c", "cd web && pnpm run start"]