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
All checks were successful
build-and-push-ext / build_push (push) Successful in 2m56s
This commit is contained in:
parent
80c091fde4
commit
baa4e19432
62
Dockerfile
62
Dockerfile
@ -1,28 +1,47 @@
|
|||||||
# syntax=docker/dockerfile:1.4
|
# syntax=docker/dockerfile:1.4
|
||||||
FROM node:19-alpine AS deps
|
FROM debian:bookworm-slim AS deps
|
||||||
WORKDIR /leCoffre-front
|
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.json ./
|
||||||
COPY package-lock.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
|
# Installation des dépendances
|
||||||
RUN --mount=type=cache,target=/root/.npm \
|
RUN --mount=type=cache,target=/root/.npm \
|
||||||
npm install --no-audit --no-fund
|
npm install --no-audit --no-fund
|
||||||
|
|
||||||
# Configuration pour le développement
|
# Configuration pour le développement
|
||||||
FROM node:19-alpine AS development
|
FROM debian:bookworm-slim AS development
|
||||||
WORKDIR /leCoffre-front
|
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/node_modules ./node_modules
|
||||||
COPY --from=deps /leCoffre-front/package.json ./package.json
|
COPY --from=deps /leCoffre-front/package.json ./package.json
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Création de l'utilisateur non-root
|
# 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
|
USER lecoffreuser
|
||||||
|
|
||||||
@ -30,9 +49,20 @@ CMD ["npm", "run", "dev"]
|
|||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# --- Build de production
|
# --- Build de production
|
||||||
FROM node:19-alpine AS builder
|
FROM debian:bookworm-slim AS builder
|
||||||
WORKDIR /leCoffre-front
|
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/node_modules ./node_modules
|
||||||
COPY --from=deps /leCoffre-front/package.json ./package.json
|
COPY --from=deps /leCoffre-front/package.json ./package.json
|
||||||
COPY . .
|
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
|
RUN --mount=type=cache,target=/leCoffre-front/.next/cache npm run build
|
||||||
|
|
||||||
# --- Image d'exécution "ext"
|
# --- Image d'exécution "ext"
|
||||||
FROM node:19-alpine AS ext
|
FROM debian:bookworm-slim AS ext
|
||||||
WORKDIR /leCoffre-front
|
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
|
# 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_PROTOCOL
|
||||||
ARG NEXT_PUBLIC_BACK_API_HOST
|
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
|
COPY --from=builder /leCoffre-front/public ./public
|
||||||
|
|
||||||
# Création de l'utilisateur non-root
|
# 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
|
USER lecoffreuser
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
Loading…
x
Reference in New Issue
Block a user