Files
strom-next/Dockerfile
T
admin 6fdf29f040 Docker-Deployment fuer nuccy
- Dockerfile (Next.js standalone, Multi-Stage) + .dockerignore
- deploy.sh fuer strom-next angepasst (Registry docker.citysensor.de,
  multiplatform build & push)
- docker-compose.prod.yml: Netzwerk 'smarthome' (external), InfluxDB als
  Host 'influx', alle Env-Defaults gesetzt, INFLUX_TOKEN aus .env
- .env.production.example (nur Token/Port), public/ fuer den Image-Build
- README: Deploy-Anleitung

Lokal verifiziert: Image baut, Container startet und liefert HTTP 200.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 16:34:24 +02:00

52 lines
1.1 KiB
Docker

# Multi-stage build for Next.js application (standalone output)
FROM node:22-alpine AS base
# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Copy package files
COPY package.json package-lock.json* ./
RUN npm ci
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Set build date as build argument
ARG BUILD_DATE
ENV NEXT_PUBLIC_BUILD_DATE=${BUILD_DATE}
# Disable telemetry during build
ENV NEXT_TELEMETRY_DISABLED=1
# Build the application
RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy necessary files
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]