|
|
|
|
|
FROM node:20-alpine AS builder |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
|
|
|
COPY package*.json ./ |
|
|
COPY tsconfig.json ./ |
|
|
|
|
|
|
|
|
RUN npm ci |
|
|
|
|
|
|
|
|
COPY . . |
|
|
|
|
|
|
|
|
RUN npm run build |
|
|
|
|
|
|
|
|
FROM node:20-alpine AS production |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
|
|
|
COPY package*.json ./ |
|
|
RUN npm ci --only=production && npm cache clean --force |
|
|
|
|
|
|
|
|
COPY --from=builder /app/dist ./dist |
|
|
|
|
|
|
|
|
COPY --from=builder /app/src/routes ./src/routes |
|
|
|
|
|
|
|
|
RUN addgroup -g 1001 -S nodejs && \ |
|
|
adduser -S nodejs -u 1001 |
|
|
|
|
|
|
|
|
RUN chown -R nodejs:nodejs /app |
|
|
|
|
|
USER nodejs |
|
|
|
|
|
|
|
|
EXPOSE 7860 |
|
|
|
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ |
|
|
CMD node -e "require('http').get('http://localhost:7860/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" |
|
|
|
|
|
|
|
|
CMD ["node", "dist/server.js"] |
|
|
|
|
|
|