Files
timetracker/Dockerfile
Felix Schlusche 11c9440806
All checks were successful
Build and Push Docker Image / build (push) Successful in 35s
feat: add version info endpoint and display in UI
2025-10-24 17:50:21 +02:00

66 lines
1.6 KiB
Docker

# Multi-stage Dockerfile for Zeiterfassung Application
# Optimized for production deployment
# ============================================
# Stage 1: Build - Install dependencies
# ============================================
FROM node:18-alpine AS builder
# Add metadata
LABEL maintainer="timetracker"
LABEL description="Time tracking application with persistent timer and German break rules"
WORKDIR /app
# Copy package files for dependency installation
COPY package*.json ./
# Install only production dependencies
RUN npm install --omit=dev && \
npm cache clean --force
# ============================================
# Stage 2: Runtime - Slim production image
# ============================================
FROM node:18-alpine
WORKDIR /app
# Install dumb-init for proper signal handling
RUN apk add --no-cache dumb-init
# Copy dependencies from builder stage
COPY --from=builder /app/node_modules ./node_modules
# Copy application files
COPY server.js ./
COPY schema.sql ./
COPY package*.json ./
COPY public ./public
# Create data directory for SQLite database
RUN mkdir -p /app/db
# Expose the application port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Set environment variables
ENV NODE_ENV=production \
PORT=3000
# Build arguments for version info
ARG COMMIT_HASH=unknown
ARG BUILD_DATE=unknown
ENV COMMIT_HASH=${COMMIT_HASH}
ENV BUILD_DATE=${BUILD_DATE}
# Use dumb-init to handle signals properly
ENTRYPOINT ["dumb-init", "--"]
# Run the application
CMD ["node", "server.js"]