You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openhamclock/Dockerfile

55 lines
1.1 KiB

# OpenHamClock Dockerfile
# Multi-stage build for optimized production image
# ============================================
# Stage 1: Build
# ============================================
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm install --omit=dev
# ============================================
# Stage 2: Production
# ============================================
FROM node:20-alpine AS production
# Set environment
ENV NODE_ENV=production
ENV PORT=3000
# Create non-root user for security
RUN addgroup -g 1001 -S nodejs && \
adduser -S openhamclock -u 1001
WORKDIR /app
# Copy node_modules from builder
COPY --from=builder /app/node_modules ./node_modules
# Copy application files
COPY package*.json ./
COPY server.js ./
COPY public ./public
# Set ownership
RUN chown -R openhamclock:nodejs /app
# Switch to non-root user
USER openhamclock
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
# Start server
CMD ["node", "server.js"]

Powered by TurnKey Linux.