ci: docker_tag=ext - Fix CI build with multi-stage Dockerfile
All checks were successful
build-and-push-ext / build_push (push) Successful in 6m39s
All checks were successful
build-and-push-ext / build_push (push) Successful in 6m39s
- Add multi-stage Dockerfile with 'ext' stage for CI compatibility - Fix start-runtime.js to use 'npm start' instead of 'node server.js' - Ensure image can be built with target stage 'ext' as expected by CI - Maintain runtime environment variable injection capability
This commit is contained in:
parent
f286d6864c
commit
8ec4300b92
26
Dockerfile
26
Dockerfile
@ -1,5 +1,7 @@
|
|||||||
# Dockerfile optimisé pour la CI - build générique, variables au runtime
|
# Dockerfile multi-stage pour la CI - build générique, variables au runtime
|
||||||
FROM docker.io/library/debian:bookworm-slim
|
|
||||||
|
# Stage de base
|
||||||
|
FROM docker.io/library/debian:bookworm-slim AS base
|
||||||
|
|
||||||
# Installation des dépendances système
|
# Installation des dépendances système
|
||||||
RUN apt-get update && apt-get upgrade -y && \
|
RUN apt-get update && apt-get upgrade -y && \
|
||||||
@ -16,6 +18,9 @@ RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash - && \
|
|||||||
|
|
||||||
WORKDIR /leCoffre-front
|
WORKDIR /leCoffre-front
|
||||||
|
|
||||||
|
# Stage de build
|
||||||
|
FROM base AS builder
|
||||||
|
|
||||||
# Copie des fichiers de dépendances
|
# Copie des fichiers de dépendances
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm install --no-audit --no-fund
|
RUN npm install --no-audit --no-fund
|
||||||
@ -47,15 +52,24 @@ ENV NEXT_PUBLIC_BACK_API_PROTOCOL=https \
|
|||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
# Stage de production (stage 'ext' pour la CI)
|
||||||
|
FROM base AS ext
|
||||||
|
|
||||||
|
# Copie des fichiers buildés depuis le stage builder
|
||||||
|
COPY --from=builder /leCoffre-front/.next ./.next
|
||||||
|
COPY --from=builder /leCoffre-front/public ./public
|
||||||
|
COPY --from=builder /leCoffre-front/package.json ./package.json
|
||||||
|
COPY --from=builder /leCoffre-front/node_modules ./node_modules
|
||||||
|
|
||||||
|
# Copie du script de démarrage
|
||||||
|
COPY start-runtime.js ./
|
||||||
|
RUN chmod +x start-runtime.js
|
||||||
|
|
||||||
# Configuration runtime
|
# Configuration runtime
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV PORT=8080
|
ENV PORT=8080
|
||||||
|
|
||||||
# Copie du script de démarrage et permissions
|
|
||||||
COPY start-runtime.js ./
|
|
||||||
RUN chmod +x start-runtime.js
|
|
||||||
|
|
||||||
# Utilisateur non-root
|
# Utilisateur non-root
|
||||||
RUN useradd -m -u 1000 lecoffreuser && \
|
RUN useradd -m -u 1000 lecoffreuser && \
|
||||||
mkdir -p /leCoffre-front && chown -R lecoffreuser:lecoffreuser /leCoffre-front
|
mkdir -p /leCoffre-front && chown -R lecoffreuser:lecoffreuser /leCoffre-front
|
||||||
|
@ -34,7 +34,7 @@ const env = { ...defaultEnv, ...process.env };
|
|||||||
console.log('Starting Next.js with runtime environment variables...');
|
console.log('Starting Next.js with runtime environment variables...');
|
||||||
|
|
||||||
// Démarrer Next.js avec les variables injectées
|
// Démarrer Next.js avec les variables injectées
|
||||||
const nextProcess = spawn('node', ['server.js'], {
|
const nextProcess = spawn('npm', ['start'], {
|
||||||
env: env,
|
env: env,
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
cwd: __dirname
|
cwd: __dirname
|
||||||
|
Loading…
x
Reference in New Issue
Block a user