feat: auto-run prisma db push on container startup

This commit is contained in:
2026-05-11 23:30:35 +08:00
parent c7ad849346
commit 3044b3d921
2 changed files with 9 additions and 1 deletions

View File

@@ -23,6 +23,8 @@ COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist COPY --from=builder /app/dist ./dist
COPY --from=builder /app/prisma ./prisma COPY --from=builder /app/prisma ./prisma
COPY start.sh ./
RUN chmod +x start.sh
EXPOSE 3001 EXPOSE 3001
CMD ["node", "dist/index.js"] CMD ["./start.sh"]

6
start.sh Normal file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
set -e
echo "▶ 同步数据库 schema..."
npx prisma db push --skip-generate
echo "▶ 启动服务..."
exec node dist/index.js