Files
slipmatz-web/Dockerfile

44 lines
903 B
Docker

# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies with clean cache
RUN npm ci --prefer-offline --no-audit
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Production stage
FROM node:20-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install only production dependencies with clean cache
RUN npm ci --prefer-offline --no-audit --omit=dev
# Copy built application from builder stage
COPY --from=builder /app/.output ./.output
# Expose port
EXPOSE 3000
# Set environment to production
ENV NODE_ENV=production
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Start the application
CMD ["node", ".output/server/index.mjs"]