fix(contribution): Dockerfile添加预种Prisma Client生成和migration

- builder和runner阶段均添加 prisma generate --schema=prisma/pre-planting/schema.prisma
- start.sh添加预种migration部署步骤

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-26 20:33:04 -08:00
parent 8d7fd68509
commit 30a2f739cb
1 changed files with 5 additions and 1 deletions

View File

@ -12,6 +12,8 @@ COPY prisma ./prisma/
RUN npm ci
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate
# [2026-02-27] 新增:生成预种计划独立 Prisma Client
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate --schema=prisma/pre-planting/schema.prisma
COPY src ./src
RUN npm run build
@ -34,10 +36,12 @@ RUN npm ci --only=production && npm cache clean --force
COPY --chown=nestjs:nodejs prisma ./prisma/
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate
# [2026-02-27] 新增:生成预种计划独立 Prisma Client
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate --schema=prisma/pre-planting/schema.prisma
COPY --chown=nestjs:nodejs --from=builder /app/dist ./dist
RUN printf '#!/bin/sh\nset -e\necho "Running database migrations..."\nnpx prisma migrate deploy\necho "Starting application..."\nexec node dist/main.js\n' > /app/start.sh && chmod +x /app/start.sh
RUN printf '#!/bin/sh\nset -e\necho "Running database migrations..."\nnpx prisma migrate deploy\necho "Running pre-planting migrations..."\nnpx prisma migrate deploy --schema=prisma/pre-planting/schema.prisma || echo "Pre-planting migration completed (or skipped)"\necho "Starting application..."\nexec node dist/main.js\n' > /app/start.sh && chmod +x /app/start.sh
ENV NODE_ENV=production
ENV TZ=Asia/Shanghai