-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (55 loc) · 2.96 KB
/
Dockerfile
File metadata and controls
65 lines (55 loc) · 2.96 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
63
64
65
# syntax=docker/dockerfile:1.7
# ─────────────────────────────────────────────────────────────────────────────
# Louis — image production multi-stage
#
# Repose sur `output: "standalone"` (cf. next.config.ts) qui génère un bundle
# Next minimal dans `.next/standalone/`. Image finale ~250 MB (vs 1+ GB pour
# une build avec node_modules complet).
#
# Build :
# docker build -t louis:dev .
#
# Run :
# docker run --rm -p 3000:3000 --env-file .env louis:dev
#
# Note LibreOffice : l'image n'inclut PAS LibreOffice. Pour le rendu DOCX→PDF
# fidèle, lancer un sidecar Gotenberg séparé (cf. docker-compose.yml) et
# pointer `GOTENBERG_URL=http://gotenberg:3000` côté Louis.
# ─────────────────────────────────────────────────────────────────────────────
FROM node:24-alpine AS deps
WORKDIR /app
# libc6-compat : utile pour certains binaires natifs (sharp, etc.)
RUN apk add --no-cache libc6-compat
COPY package.json package-lock.json ./
RUN npm ci --no-audit --no-fund
# ─────────────────────────────────────────────────────────────────────────────
FROM node:24-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Placeholders nécessaires au build Next (la vraie config est injectée au run).
ENV NEXT_TELEMETRY_DISABLED=1
ENV DATABASE_URL=postgresql://placeholder:placeholder@localhost:5432/placeholder
ENV AUTH_SECRET=build_placeholder_secret_long_enough_for_nextauth_validation
ENV ENCRYPTION_KEY=build_placeholder_key_32_chars_long_for_aes256_scrypt_test
RUN npm run build
# ─────────────────────────────────────────────────────────────────────────────
FROM node:24-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# User non-root pour l'exécution
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
# Public assets (favicon, icon.svg, etc.) + sortie standalone de Next
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
# Health probe interne (utilisée par compose / k8s si pas de probe HTTP externe)
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:${PORT}/api/health || exit 1
USER nextjs
EXPOSE 3000
CMD ["node", "server.js"]