Files
jiawei 059cad8e27
ocs-nuxt / deploy (push) Successful in 1m49s
feat: 添加容器时区设置
2026-05-24 00:33:44 +08:00

29 lines
1.0 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ocs-nuxt 应用镜像
# 构建流程:pnpm install(含 postinstall: prisma generate + nuxt prepare)→ nuxt build → node 启动
FROM ocs-base:latest
WORKDIR /app
# 复制所有源码(node_modules/.nuxt/.output 已在 .dockerignore 中排除)
COPY . .
# prisma.config.ts 中 env("DATABASE_URL") 在加载时即校验,构建阶段不连接数据库
# 此处仅为 prisma generate 提供占位值,运行时由容器环境变量覆盖
ARG DATABASE_URL=mysql://build:build@localhost:3306/build
ENV DATABASE_URL=$DATABASE_URL
# 安装依赖并触发 postinstallprisma generate + nuxt prepare
# --frozen-lockfile 确保版本与 pnpm-lock.yaml 严格一致
RUN pnpm install --frozen-lockfile
# 构建 Nuxt 应用,输出到 .output/
RUN pnpm build
# Nuxt server 默认监听 3000,可通过 PORT 环境变量覆盖
ENV PORT=3000
# 容器时区设为 CST,确保 date.getHours() 等本地时间方法返回正确的北京时间
ENV TZ=Asia/Shanghai
EXPOSE 3000
CMD ["node", ".output/server/index.mjs"]