Compare commits
No commits in common. "8f616dd45bb10830cf854ca0a10447937fc97b73" and "f4380604d952808b452ba1732986f3d47c103b74" have entirely different histories.
8f616dd45b
...
f4380604d9
|
|
@ -0,0 +1,8 @@
|
|||
node_modules
|
||||
dist
|
||||
.git
|
||||
.gitignore
|
||||
*.md
|
||||
*.log
|
||||
.env*
|
||||
prisma/seed.ts
|
||||
|
|
@ -14,7 +14,7 @@ RUN npm ci
|
|||
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate
|
||||
|
||||
COPY src ./src
|
||||
RUN npm run build
|
||||
RUN npm run build && ls -la dist/ && test -f dist/main.js
|
||||
|
||||
# 阶段2: 生产运行
|
||||
FROM node:20-alpine AS runner
|
||||
|
|
@ -30,15 +30,14 @@ WORKDIR /app
|
|||
USER nestjs
|
||||
|
||||
COPY --chown=nestjs:nodejs package*.json ./
|
||||
COPY --chown=nestjs:nodejs tsconfig*.json ./
|
||||
RUN npm ci --only=production && npm install ts-node typescript @types/node --save-dev && npm cache clean --force
|
||||
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
|
||||
|
||||
COPY --chown=nestjs:nodejs --from=builder /app/dist ./dist
|
||||
|
||||
RUN printf '#!/bin/sh\nset -e\necho "Running database migrations..."\nnpx prisma migrate deploy\necho "Running database seed..."\nnpx prisma db seed || echo "Seed skipped or already applied"\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 "Starting application..."\nexec node dist/main.js\n' > /app/start.sh && chmod +x /app/start.sh
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
|
|
|||
|
|
@ -20,5 +20,7 @@
|
|||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "prisma"]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue