- Created 'entries' table to track time entries with fields for date, start time, end time, pause minutes, location, and entry type. - Created 'settings' table to store key-value pairs for application settings with an updated timestamp.
60 lines
1.5 KiB
Docker
60 lines
1.5 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
|
|
|
|
# Use dumb-init to handle signals properly
|
|
ENTRYPOINT ["dumb-init", "--"]
|
|
|
|
# Run the application
|
|
CMD ["node", "server.js"]
|