-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (50 loc) · 1.81 KB
/
Dockerfile
File metadata and controls
62 lines (50 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Shipvisualization – Docker für Coolify
# Next.js 15 Standalone Build
FROM node:20-alpine AS base
RUN apk add --no-cache libc6-compat
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Dependencies (inkl. devDependencies für Build: tailwind, postcss, typescript, etc.)
FROM base AS deps
RUN apk add --no-cache util-linux
WORKDIR /app
COPY package.json package-lock.json* ./
ENV NODE_ENV=development
# CPU-Limit auch für npm ci (BUILD_CPUS wird im builder gesetzt, hier Default)
ARG BUILD_CPUS=1
RUN if [ "$BUILD_CPUS" -gt 0 ] 2>/dev/null; then \
nice -n 19 taskset -c $(seq -s, 0 $((BUILD_CPUS-1))) npm ci; \
else nice -n 19 npm ci; fi
# Builder
FROM base AS builder
RUN apk add --no-cache util-linux
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ARG NEXT_PUBLIC_ZSG_API_URL
ENV NEXT_PUBLIC_ZSG_API_URL=${NEXT_PUBLIC_ZSG_API_URL}
ENV NODE_ENV=production
# Weniger parallele Jobs (weniger CPU-Spitzen)
ENV CI=true
# CPU-Limit: BUILD_CPUS=1 (Default) = nur 1 CPU, weniger Load. 0 = alle CPUs.
# nice -n 19 = niedrigste Priorität, stiehlt anderen Prozessen keine CPU.
ARG BUILD_CPUS=1
RUN if [ "$BUILD_CPUS" -gt 0 ] 2>/dev/null; then \
nice -n 19 taskset -c $(seq -s, 0 $((BUILD_CPUS-1))) npm run build; \
else nice -n 19 npm run build; fi
# Runner
FROM base AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
# Standalone + public + static (Next.js)
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
# data/ wird zur Laufzeit von admin-config gelesen
COPY --from=builder --chown=nextjs:nodejs /app/data ./data
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]