44 lines
1.2 KiB
Docker
44 lines
1.2 KiB
Docker
# Observatory Simulation - Multi-stage Docker Build
|
|
|
|
# Build Stage
|
|
FROM node:20-alpine AS builder
|
|
|
|
LABEL maintainer="Observatory Simulation"
|
|
LABEL description="Teleskop und Kuppel Simulation mit WebSocket-Architektur"
|
|
|
|
WORKDIR /app
|
|
|
|
# Kopiere package files für optimale Layer-Caching
|
|
COPY package*.json ./
|
|
|
|
# Installiere nur Production Dependencies
|
|
RUN npm ci --only=production && npm cache clean --force
|
|
|
|
# Production Stage
|
|
FROM node:20-alpine AS production
|
|
|
|
# Erstelle non-root user für Sicherheit
|
|
RUN addgroup -g 1001 -S nodejs && \
|
|
adduser -S observatory -u 1001
|
|
|
|
WORKDIR /app
|
|
|
|
# Kopiere node_modules aus Build Stage
|
|
COPY --from=builder --chown=observatory:nodejs /app/node_modules ./node_modules
|
|
|
|
# Kopiere Application Code
|
|
COPY --chown=observatory:nodejs server.js ./
|
|
COPY --chown=observatory:nodejs public ./public/
|
|
|
|
# Wechsle zu non-root user
|
|
USER observatory
|
|
|
|
# Expose Port für WebSocket Server
|
|
EXPOSE 3005
|
|
|
|
# Health Check für Container-Monitoring
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD node -e "require('http').get('http://localhost:3005', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) }).on('error', () => process.exit(1))"
|
|
|
|
# Starte Observatory Simulation
|
|
CMD ["node", "server.js"] |