ci: docker_tag=ext - Migrate to Debian base with minimal packages
All checks were successful
build-and-push-ext / build_push (push) Successful in 2m56s

This commit is contained in:
Debian Dev4 2025-09-21 18:25:09 +00:00
parent 80c091fde4
commit baa4e19432

View File

@ -1,28 +1,47 @@
# syntax=docker/dockerfile:1.4
FROM node:19-alpine AS deps
FROM debian:bookworm-slim AS deps
WORKDIR /leCoffre-front
# Installation des dépendances de base
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --fix-missing \
ca-certificates curl jq git && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Installation de Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash - && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY package.json ./
COPY package-lock.json ./
RUN apk update && apk upgrade && apk add --no-cache \
git \
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/*
# Installation des dépendances
RUN --mount=type=cache,target=/root/.npm \
npm install --no-audit --no-fund
# Configuration pour le développement
FROM node:19-alpine AS development
FROM debian:bookworm-slim AS development
WORKDIR /leCoffre-front
# Installation des dépendances de base
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --fix-missing \
ca-certificates curl jq git && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Installation de Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash - && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY --from=deps /leCoffre-front/node_modules ./node_modules
COPY --from=deps /leCoffre-front/package.json ./package.json
COPY . .
# Création de l'utilisateur non-root
RUN adduser -D lecoffreuser --uid 10000 && chown -R lecoffreuser .
RUN useradd -m -u 1000 lecoffreuser && \
mkdir -p /leCoffre-front && chown -R lecoffreuser:lecoffreuser /leCoffre-front
USER lecoffreuser
@ -30,9 +49,20 @@ CMD ["npm", "run", "dev"]
EXPOSE 3000
# --- Build de production
FROM node:19-alpine AS builder
FROM debian:bookworm-slim AS builder
WORKDIR /leCoffre-front
# Installation des dépendances de base
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --fix-missing \
ca-certificates curl jq git && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Installation de Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash - && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY --from=deps /leCoffre-front/node_modules ./node_modules
COPY --from=deps /leCoffre-front/package.json ./package.json
COPY . .
@ -81,9 +111,20 @@ ENV NEXT_PUBLIC_BACK_API_PROTOCOL=${NEXT_PUBLIC_BACK_API_PROTOCOL} \
RUN --mount=type=cache,target=/leCoffre-front/.next/cache npm run build
# --- Image d'exécution "ext"
FROM node:19-alpine AS ext
FROM debian:bookworm-slim AS ext
WORKDIR /leCoffre-front
# Installation des dépendances de base
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --fix-missing \
ca-certificates curl jq git && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Installation de Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash - && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Re-déclarer les ARG pour l'étape runtime et les exposer en ENV
ARG NEXT_PUBLIC_BACK_API_PROTOCOL
ARG NEXT_PUBLIC_BACK_API_HOST
@ -133,7 +174,8 @@ COPY --from=builder /leCoffre-front/.next/static ./.next/static
COPY --from=builder /leCoffre-front/public ./public
# Création de l'utilisateur non-root
RUN adduser -D lecoffreuser --uid 10000 && chown -R lecoffreuser .
RUN useradd -m -u 1000 lecoffreuser && \
mkdir -p /leCoffre-front && chown -R lecoffreuser:lecoffreuser /leCoffre-front
USER lecoffreuser
EXPOSE 3000