spawner/user-template-next/Dockerfile
XPS\Micro cd91992333 fix: add fallback to npm install for user-template-next
- Use npm ci only if package-lock.json exists
- Falls back to npm install if not present
- Allows flexible package installation without strict lockfile requirement
2026-01-31 18:34:06 +01:00

39 lines
1017 B
Docker

# Build stage
FROM node:20.11-alpine AS builder
WORKDIR /app
# Copy nur package.json (Layer Caching - schneller Rebuilds wenn Source-Code aendert)
COPY package*.json ./
# Installiere alle Packages (incl. devDependencies fuer TypeScript Build)
# Fallback zu npm install wenn package-lock.json nicht existiert
RUN if [ -f package-lock.json ]; then npm ci --prefer-offline --no-audit; else npm install; fi && \
npm cache clean --force
# Copy Source Code
COPY . .
# Build Next.js App (generiert /app/.next output)
RUN npm run build
# Production stage - serve static files with nginx
FROM nginx:alpine
# Copy nur das Build-Output (Rest wird nicht mehr benoetigt)
COPY --from=builder /app/out /usr/share/nginx/html
# Nginx config fuer SPA (Single Page App)
RUN echo 'server { \
listen 8080; \
root /usr/share/nginx/html; \
index index.html; \
location / { \
try_files $uri $uri/ /index.html; \
} \
}' > /etc/nginx/conf.d/default.conf
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]