auf docker umgestellt
This commit is contained in:
44
JS/Dockerfile
Normal file
44
JS/Dockerfile
Normal file
@@ -0,0 +1,44 @@
|
||||
# Observatory Simulation - Multi-stage Docker Build
|
||||
|
||||
# Build Stage
|
||||
FROM node:18-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:18-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"]
|
||||
Reference in New Issue
Block a user