spawner/user-template-next/Dockerfile
XPS\Micro 2016767dcb perf: make user-template-next optional and optimize build process
Changes:
- install.sh: user-template-next is now only built if USER_TEMPLATE_IMAGE=user-template-next:latest is set in .env
  * Defaults to user-service-template (nginx) to save 4-5 minutes per install
  * Dynamic build step counting based on configured templates
  * Shows helpful message when template is skipped
  * Build numbering adapts automatically ([1/3] vs [1/4])

- user-template-next/Dockerfile: Optimize build performance
  * Pin Node version to 20.11-alpine for reproducibility
  * Use npm ci instead of npm install for faster, reproducible builds
  * Separate package.json copy for better layer caching
  * Add --prefer-offline and --no-audit flags to npm ci
  * Clean npm cache to reduce image size
  * Add clear comments for multi-stage build steps

Impact:
- Default installations: 2-3 minutes faster
- Reduced build time for Next.js template (when enabled) via layer caching
- Better reproducibility and predictable builds
2026-01-31 16:43:10 +01:00

38 lines
896 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)
RUN npm ci --prefer-offline --no-audit && \
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;"]