Dockerfile modif2
This commit is contained in:
parent
401146a34a
commit
3548eabf68
@ -1,14 +1,14 @@
|
||||
# Dépendances — réinstallées dans le conteneur
|
||||
# ─── Dépendances ───────────────────────────────────────────
|
||||
node_modules
|
||||
.pnp
|
||||
.pnp.js
|
||||
|
||||
# Artefacts de build
|
||||
# ─── Artefacts de build ────────────────────────────────────
|
||||
.next
|
||||
out
|
||||
dist
|
||||
|
||||
# Outils de dev
|
||||
# ─── Outils de développement ───────────────────────────────
|
||||
.git
|
||||
.gitignore
|
||||
.github
|
||||
@ -18,30 +18,31 @@ npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Secrets locaux — jamais dans l'image
|
||||
# ─── Secrets locaux — jamais dans l'image ──────────────────
|
||||
# Les valeurs NEXT_PUBLIC_* passent via --build-arg / docker-compose
|
||||
# Les secrets (SERVICE_ROLE_KEY) sont injectés au runtime via --env-file
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
!.env.local.example
|
||||
|
||||
# Tests / CI
|
||||
# ─── Tests / CI ────────────────────────────────────────────
|
||||
coverage
|
||||
.nyc_output
|
||||
__tests__
|
||||
*.test.ts
|
||||
*.spec.ts
|
||||
|
||||
# Docs
|
||||
# ─── Documentation ─────────────────────────────────────────
|
||||
*.md
|
||||
!README.md
|
||||
|
||||
# Docker
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
# ─── Docker ────────────────────────────────────────────────
|
||||
docker-compose.yml
|
||||
docker-compose*.yml
|
||||
|
||||
# Supabase
|
||||
# ─── Supabase (migrations locales) ─────────────────────────
|
||||
supabase/
|
||||
|
||||
# Divers
|
||||
# ─── Divers ────────────────────────────────────────────────
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
quiz-example.json
|
||||
|
||||
23
Dockerfile
23
Dockerfile
@ -9,7 +9,6 @@ WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json* ./
|
||||
|
||||
# ci : installation déterministe depuis le lock-file
|
||||
RUN npm ci
|
||||
|
||||
|
||||
@ -25,15 +24,19 @@ WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Variables publiques (NEXT_PUBLIC_*) nécessaires au build.
|
||||
# Les secrets serveur (SERVICE_ROLE_KEY…) ne sont JAMAIS passés ici.
|
||||
ARG NEXT_PUBLIC_SUPABASE_URL
|
||||
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||
# Variables publiques nécessaires à la compilation du bundle client.
|
||||
# Passer via --build-arg ou docker-compose (voir docker-compose.yml).
|
||||
# Les valeurs vides sont acceptées : les pages sont dynamiques (cookies),
|
||||
# donc aucune pré-rendu statique ne les utilise au build.
|
||||
ARG NEXT_PUBLIC_SUPABASE_URL=""
|
||||
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY=""
|
||||
|
||||
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL \
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY \
|
||||
NEXT_TELEMETRY_DISABLED=1 \
|
||||
NODE_ENV=production
|
||||
NODE_ENV=production \
|
||||
# Allouer suffisamment de mémoire pour le build Next.js
|
||||
NODE_OPTIONS="--max-old-space-size=4096"
|
||||
|
||||
RUN npm run build
|
||||
|
||||
@ -54,7 +57,7 @@ RUN addgroup --system --gid 1001 nodejs && \
|
||||
# Fichiers publics (favicon, images statiques…)
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
# Serveur Next.js standalone (bundle minimal sans node_modules complets)
|
||||
# Serveur Next.js standalone (bundle minimal, sans node_modules complets)
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
|
||||
# Assets statiques compilés (_next/static)
|
||||
@ -67,10 +70,10 @@ ENV NODE_ENV=production \
|
||||
PORT=3000 \
|
||||
HOSTNAME="0.0.0.0"
|
||||
|
||||
# Les secrets injectés au runtime (jamais dans l'image) :
|
||||
# Secrets injectés au runtime uniquement (jamais baked dans l'image) :
|
||||
# NEXT_PUBLIC_SUPABASE_URL
|
||||
# NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||
# SUPABASE_SERVICE_ROLE_KEY
|
||||
# NEXT_PUBLIC_SUPABASE_URL (si non baked au build)
|
||||
# NEXT_PUBLIC_SUPABASE_ANON_KEY (si non baked au build)
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
|
||||
26
docker-compose.yml
Normal file
26
docker-compose.yml
Normal file
@ -0,0 +1,26 @@
|
||||
services:
|
||||
solyquiz:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
# Les variables NEXT_PUBLIC_* sont lues depuis le fichier .env
|
||||
# grâce à env_file, puis transmises comme build args
|
||||
args:
|
||||
NEXT_PUBLIC_SUPABASE_URL: ${NEXT_PUBLIC_SUPABASE_URL}
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${NEXT_PUBLIC_SUPABASE_ANON_KEY}
|
||||
image: solyquiz:latest
|
||||
container_name: solyquiz
|
||||
ports:
|
||||
- "3000:3000"
|
||||
# Secrets injectés uniquement au runtime (non présents dans l'image)
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
restart: unless-stopped
|
||||
# Limite les ressources pour éviter les abus
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 512m
|
||||
cpus: "1.0"
|
||||
Loading…
x
Reference in New Issue
Block a user