Dockerfile 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. FROM registry.cn-beijing.aliyuncs.com/d8dcloud/node:20.19.4-bookworm
  2. # 清除所有现有的APT源配置
  3. RUN rm -rf /etc/apt/sources.list.d/* && \
  4. echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
  5. echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
  6. echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
  7. echo "deb http://mirrors.tuna.tsinghua.edu.cn/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.npmmirror.com/
  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. # 复制根目录配置文件
  33. COPY package.json pnpm-workspace.yaml pnpm-lock.yaml ./
  34. # 复制各项目 package.json
  35. COPY web/package.json ./web/
  36. COPY packages/ ./packages/
  37. COPY allin-packages/ ./allin-packages/
  38. # 安装依赖
  39. RUN pnpm install --frozen-lockfile
  40. # 复制项目文件
  41. COPY . .
  42. # 构建 web 应用
  43. RUN cd web && pnpm run build
  44. # 暴露端口(根据实际需要调整)
  45. EXPOSE 8080
  46. # 启动命令
  47. CMD ["sh", "-c", "cd web && pnpm run start"]