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
|
node_modules
|
||||||
.pnp
|
.pnp
|
||||||
.pnp.js
|
.pnp.js
|
||||||
|
|
||||||
# Artefacts de build
|
# ─── Artefacts de build ────────────────────────────────────
|
||||||
.next
|
.next
|
||||||
out
|
out
|
||||||
dist
|
dist
|
||||||
|
|
||||||
# Outils de dev
|
# ─── Outils de développement ───────────────────────────────
|
||||||
.git
|
.git
|
||||||
.gitignore
|
.gitignore
|
||||||
.github
|
.github
|
||||||
@ -18,30 +18,31 @@ npm-debug.log*
|
|||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.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.*
|
.env.*
|
||||||
!.env.example
|
|
||||||
!.env.local.example
|
!.env.local.example
|
||||||
|
|
||||||
# Tests / CI
|
# ─── Tests / CI ────────────────────────────────────────────
|
||||||
coverage
|
coverage
|
||||||
.nyc_output
|
.nyc_output
|
||||||
__tests__
|
__tests__
|
||||||
*.test.ts
|
*.test.ts
|
||||||
*.spec.ts
|
*.spec.ts
|
||||||
|
|
||||||
# Docs
|
# ─── Documentation ─────────────────────────────────────────
|
||||||
*.md
|
*.md
|
||||||
!README.md
|
|
||||||
|
|
||||||
# Docker
|
# ─── Docker ────────────────────────────────────────────────
|
||||||
Dockerfile
|
docker-compose.yml
|
||||||
.dockerignore
|
docker-compose*.yml
|
||||||
|
|
||||||
# Supabase
|
# ─── Supabase (migrations locales) ─────────────────────────
|
||||||
supabase/
|
supabase/
|
||||||
|
|
||||||
# Divers
|
# ─── Divers ────────────────────────────────────────────────
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
quiz-example.json
|
||||||
|
|||||||
23
Dockerfile
23
Dockerfile
@ -9,7 +9,6 @@ WORKDIR /app
|
|||||||
|
|
||||||
COPY package.json package-lock.json* ./
|
COPY package.json package-lock.json* ./
|
||||||
|
|
||||||
# ci : installation déterministe depuis le lock-file
|
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
|
|
||||||
@ -25,15 +24,19 @@ WORKDIR /app
|
|||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Variables publiques (NEXT_PUBLIC_*) nécessaires au build.
|
# Variables publiques nécessaires à la compilation du bundle client.
|
||||||
# Les secrets serveur (SERVICE_ROLE_KEY…) ne sont JAMAIS passés ici.
|
# Passer via --build-arg ou docker-compose (voir docker-compose.yml).
|
||||||
ARG NEXT_PUBLIC_SUPABASE_URL
|
# Les valeurs vides sont acceptées : les pages sont dynamiques (cookies),
|
||||||
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
|
# 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 \
|
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL \
|
||||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY \
|
NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY \
|
||||||
NEXT_TELEMETRY_DISABLED=1 \
|
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
|
RUN npm run build
|
||||||
|
|
||||||
@ -54,7 +57,7 @@ RUN addgroup --system --gid 1001 nodejs && \
|
|||||||
# Fichiers publics (favicon, images statiques…)
|
# Fichiers publics (favicon, images statiques…)
|
||||||
COPY --from=builder /app/public ./public
|
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 ./
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||||
|
|
||||||
# Assets statiques compilés (_next/static)
|
# Assets statiques compilés (_next/static)
|
||||||
@ -67,10 +70,10 @@ ENV NODE_ENV=production \
|
|||||||
PORT=3000 \
|
PORT=3000 \
|
||||||
HOSTNAME="0.0.0.0"
|
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
|
# 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
|
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