steam-oauth-middleware/Dockerfile

54 lines
No EOL
1 KiB
Docker

# Build stage
FROM node:20-alpine AS builder
# Add non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Create app directory
WORKDIR /usr/src/app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Build TypeScript
RUN npm run build
# Production stage
FROM node:20-alpine
# Add non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Set working directory
WORKDIR /usr/src/app
# Copy package files
COPY package*.json ./
# Install production dependencies only
RUN npm ci --only=production
# Copy built files from builder stage
COPY --from=builder /usr/src/app/dist ./dist
# Set ownership to non-root user
RUN chown -R appuser:appgroup /usr/src/app
# Switch to non-root user
USER appuser
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
# Expose port
EXPOSE 3000
# Start the application
CMD ["npm", "start"]