fix(docker): use clean multi-stage build without inherited GPG_KEY

This commit is contained in:
bolbol committed 2026-11-10 00:15:50 +00:00
1 parent 03d9922066
commit 17e2ec47b2
1 file changed
+21 -14
+21 -14
View File
@@ -1,35 +1,42 @@
FROM python:3.11-slim # Étape 1 : Construction et installation des dépendances
FROM python:3.11-slim AS builder
# Dépendances système et polices
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
curl \ curl \
ca-certificates \ ca-certificates \
xz-utils \ xz-utils \
libfontconfig1 \
fonts-dejavu \
fonts-freefont-ttf \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Typst 0.15.1 officiel # Typst 0.15.1 officiel
RUN curl -sSL https://github.com/typst/typst/releases/download/v0.15.1/typst-x86_64-unknown-linux-musl.tar.xz | tar -xJ -C /tmp \ RUN curl -sSL https://github.com/typst/typst/releases/download/v0.15.1/typst-x86_64-unknown-linux-musl.tar.xz | tar -xJ -C /tmp \
&& mv /tmp/typst-x86_64-unknown-linux-musl/typst /usr/local/bin/typst \ && mv /tmp/typst-x86_64-unknown-linux-musl/typst /usr/local/bin/typst \
&& chmod +x /usr/local/bin/typst \ && chmod +x /usr/local/bin/typst \
&& rm -rf /tmp/typst* \ && rm -rf /tmp/typst*
&& typst --version
WORKDIR /build
COPY requirements.txt /build/
RUN pip install --no-cache-dir -r requirements.txt
# Étape 2 : Image d'exécution propre sans variables GPG_KEY héritées
FROM debian:bookworm-slim
ENV PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
ENV MPLCONFIGDIR=/tmp/matplotlib
RUN apt-get update && apt-get install -y --no-install-recommends \
libfontconfig1 \
fonts-dejavu \
fonts-freefont-ttf \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local /usr/local
# Création de l'utilisateur non-root 1005:1005
RUN groupadd -g 1005 gemini2-ops && useradd -u 1005 -g 1005 -m -s /bin/bash gemini2-ops RUN groupadd -g 1005 gemini2-ops && useradd -u 1005 -g 1005 -m -s /bin/bash gemini2-ops
WORKDIR /app WORKDIR /app
# Dépendances Python
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt
# Code source applicatif
COPY . /app/ COPY . /app/
# Préparation des dossiers montés
RUN mkdir -p /app/jobs /app/data /app/ref /app/exemples \ RUN mkdir -p /app/jobs /app/data /app/ref /app/exemples \
&& chown -R 1005:1005 /app && chown -R 1005:1005 /app