
Some checks failed
build-and-push-ext / build_push (push) Failing after 6s
- Add Dockerfile.ci for generic builds without hardcoded environment variables - Add start-runtime.js script to inject NEXT_PUBLIC_* variables at runtime - Add .env.example with default values for development - Remove dependency on build-time ARG variables for CI compatibility - Image can now be deployed to any environment with different variables
67 lines
2.3 KiB
Docker
67 lines
2.3 KiB
Docker
# Dockerfile optimisé pour la CI - build générique, variables au runtime
|
|
FROM docker.io/library/debian:bookworm-slim
|
|
|
|
# Installation des dépendances système
|
|
RUN apt-get update && apt-get upgrade -y && \
|
|
apt-get install -y --fix-missing \
|
|
ca-certificates curl jq git \
|
|
net-tools iputils-ping dnsutils \
|
|
netcat-openbsd telnet procps && \
|
|
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/*
|
|
|
|
WORKDIR /leCoffre-front
|
|
|
|
# Copie des fichiers de dépendances
|
|
COPY package.json package-lock.json ./
|
|
RUN npm install --no-audit --no-fund
|
|
|
|
# Copie du code source
|
|
COPY . .
|
|
|
|
# Build avec des variables génériques (surchargées au runtime)
|
|
ENV NEXT_PUBLIC_BACK_API_PROTOCOL=https \
|
|
NEXT_PUBLIC_BACK_API_HOST=localhost \
|
|
NEXT_PUBLIC_BACK_API_PORT=443 \
|
|
NEXT_PUBLIC_BACK_API_ROOT_URL=/api \
|
|
NEXT_PUBLIC_BACK_API_VERSION=v1 \
|
|
NEXT_PUBLIC_FRONT_APP_HOST=http://localhost:3000 \
|
|
NEXT_PUBLIC_IDNOT_BASE_URL=https://qual-connexion.idnot.fr \
|
|
NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT=/IdPOAuth2/authorize/idnot_idp_v1 \
|
|
NEXT_PUBLIC_IDNOT_CLIENT_ID=default_client_id \
|
|
NEXT_PUBLIC_IDNOT_REDIRECT_URI=http://localhost:3000/authorized-client \
|
|
NEXT_PUBLIC_IDNOT_REDIRECT_URI_FIXED=http://local.4nkweb.com:3000/authorized-client \
|
|
NEXT_PUBLIC_4NK_URL=http://localhost:3000 \
|
|
NEXT_PUBLIC_4NK_IFRAME_URL=http://localhost:3000 \
|
|
NEXT_PUBLIC_BACK_BASE=http://localhost:8080 \
|
|
NEXT_PUBLIC_API_URL=http://localhost:8080/api \
|
|
NEXT_PUBLIC_DEFAULT_VALIDATOR_ID=default_validator_id \
|
|
NEXT_PUBLIC_DEFAULT_STORAGE_URLS=http://localhost:8080/storage \
|
|
NEXT_PUBLIC_DOCAPOSTE_API_URL= \
|
|
NEXT_PUBLIC_HOTJAR_SITE_ID= \
|
|
NEXT_PUBLIC_HOTJAR_VERSION=
|
|
|
|
RUN npm run build
|
|
|
|
# Configuration runtime
|
|
EXPOSE 8080
|
|
ENV NODE_ENV=production
|
|
ENV PORT=8080
|
|
|
|
# Copie du script de démarrage et permissions
|
|
COPY start-runtime.js ./
|
|
RUN chmod +x start-runtime.js
|
|
|
|
# Utilisateur non-root
|
|
RUN useradd -m -u 1000 lecoffreuser && \
|
|
mkdir -p /leCoffre-front && chown -R lecoffreuser:lecoffreuser /leCoffre-front
|
|
|
|
USER lecoffreuser
|
|
|
|
# Utiliser le script de démarrage qui injecte les variables au runtime
|
|
CMD ["node", "start-runtime.js"]
|