-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
118 lines (98 loc) · 4.19 KB
/
Copy pathDockerfile
File metadata and controls
118 lines (98 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# NEXOS — Dockerfile multi-stage
# Phase J du chantier mise_a_niveau (v4.2.0).
#
# Build: docker build -t nexos:dev .
# Run: docker run --rm -it nexos:dev nexos doctor
# Gateway: docker run --rm -p 8000:8000 nexos:dev uvicorn nexos_gateway:app --host 0.0.0.0
# =========================================================
# Stage 1 — builder : installe les deps Python + Node
# =========================================================
FROM python:3.11-slim AS builder
# Variables de build
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1
# Deps système nécessaires au build + Node via nodesource
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
gnupg \
git \
build-essential \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Workdir
WORKDIR /app
# Copier pyproject.toml + lockfile pour installer deps (cache efficace)
COPY pyproject.toml ./
# Lockfile selon outil choisi en phase C
COPY uv.lock* poetry.lock* requirements.lock* ./
# Créer venv isolé
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Installer pip tools + deps
RUN pip install --upgrade pip setuptools wheel
# Copier le reste du code
COPY . .
# SOIC est un repo séparé (AILabManager-tech/soic, public).
# Installé directement via pip depuis le remote — pas de symlink local
# ni de build-context, ce qui rend l'image reproductible en CI sans
# docker-compose (le bind-mount local reste possible côté dev override).
RUN pip install "soic @ git+https://github.com/AILabManager-tech/soic.git@main"
# Installer NEXOS en editable avec tous les extras sauf dev
# (dev contient mypy/ruff/pytest : pas utiles en runtime)
RUN pip install -e ".[api,wizard]"
# =========================================================
# Stage 2 — runtime : image minimale
# =========================================================
FROM python:3.11-slim AS runtime
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PATH="/opt/venv/bin:/usr/local/bin:/usr/bin:/bin" \
NEXOS_LOG_LEVEL=INFO
# Deps runtime minimales (passwd fournit useradd, absent du slim)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
git \
passwd \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Node 20 via nodesource (runtime) + tooling Lighthouse/pa11y
# Installé directement ici (et non copié depuis le builder) pour préserver les
# symlinks /usr/bin/* créés par npm — un COPY déréférencerait le lien vers le
# script JS et casserait le résoudre des modules Node relatifs.
# PUPPETEER_SKIP_DOWNLOAD=true évite que pa11y/lighthouse téléchargent
# leur propre Chromium (~700 MB) à l'install global. En CI/usage local,
# le système Chromium ou un chromium custom fait l'affaire.
# PUPPETEER_CACHE_DIR contrôle où puppeteer met ses caches (vide ici).
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& PUPPETEER_SKIP_DOWNLOAD=true \
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
npm install -g lighthouse pa11y --omit=optional \
&& npm cache clean --force \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /root/.cache /tmp/*
# Créer un user non-root (useradd vit dans /usr/sbin, hors du PATH explicite)
RUN /usr/sbin/useradd -m -u 1000 -s /bin/bash nexos
# Copier venv et code depuis le builder
COPY --from=builder /opt/venv /opt/venv
COPY --from=builder --chown=nexos:nexos /app /app
WORKDIR /app
USER nexos
# Exposer le port du gateway (si utilisé)
EXPOSE 8000
# Entry point : par défaut affiche l'aide
# Override via CLI: docker run nexos:dev nexos doctor
ENTRYPOINT []
CMD ["nexos", "--help"]
# Labels OCI
LABEL org.opencontainers.image.title="NEXOS"
LABEL org.opencontainers.image.description="NEXOS pipeline web autonome avec quality gates SOIC"
LABEL org.opencontainers.image.version="4.2.0-dev"
LABEL org.opencontainers.image.source="https://github.com/YOUR_ORG/nexos"
LABEL org.opencontainers.image.licenses="Proprietary"