|
1 | | -FROM python:3.11-alpine |
| 1 | +# == Builder Stage: Install dependencies with build tools == |
| 2 | +FROM python:3.12-alpine AS builder |
2 | 3 |
|
3 | | -ENV PYTHONDONTWRITEBYTECODE 1 |
4 | | -ENV PYTHONUNBUFFERED 1 |
| 4 | +ENV PYTHONDONTWRITEBYTECODE=1 \ |
| 5 | + PYTHONUNBUFFERED=1 \ |
| 6 | + PIP_NO_CACHE_DIR=1 \ |
| 7 | + PIP_DISABLE_PIP_VERSION_CHECK=1 |
5 | 8 |
|
6 | | -# Set build directory |
7 | | -WORKDIR /tmp |
| 9 | +WORKDIR /build |
8 | 10 |
|
9 | | -# Install pip requirements |
10 | | -ADD requirements*.txt ./ |
| 11 | +# Install build dependencies |
| 12 | +RUN apk add --no-cache \ |
| 13 | + gcc \ |
| 14 | + musl-dev \ |
| 15 | + libffi-dev \ |
| 16 | + openssl-dev \ |
| 17 | + cairo-dev \ |
| 18 | + pango-dev \ |
| 19 | + gdk-pixbuf-dev |
11 | 20 |
|
12 | | -# Perform build and cleanup artifacts |
13 | | -RUN \ |
14 | | - apk add --no-cache \ |
| 21 | +# Copy and install Python dependencies |
| 22 | +COPY requirements.txt ./ |
| 23 | +RUN python -m venv /opt/venv \ |
| 24 | + && /opt/venv/bin/pip install --upgrade pip \ |
| 25 | + && /opt/venv/bin/pip install -r requirements.txt |
| 26 | + |
| 27 | + |
| 28 | +# == Runtime Stage: Minimal image for development == |
| 29 | + |
| 30 | +FROM python:3.12-alpine |
| 31 | + |
| 32 | +LABEL org.opencontainers.image.title="Geotribu Website Stack" \ |
| 33 | + org.opencontainers.image.description="Technical stack to build Geotribu website." \ |
| 34 | + org.opencontainers.image.source="https://github.com/geotribu/website/" \ |
| 35 | + org.opencontainers.image.licenses="GPL-3.0-or-later" |
| 36 | + |
| 37 | +ENV PYTHONDONTWRITEBYTECODE=1 \ |
| 38 | + PYTHONUNBUFFERED=1 \ |
| 39 | + PYTHONOPTIMIZE=2 \ |
| 40 | + LANG=fr_FR.UTF-8 \ |
| 41 | + LANGUAGE=fr_FR:fr \ |
| 42 | + LC_ALL=fr_FR.UTF-8 \ |
| 43 | + PATH="/opt/venv/bin:$PATH" |
| 44 | + |
| 45 | +# Install runtime dependencies including French locale support |
| 46 | +RUN apk add --no-cache \ |
15 | 47 | git \ |
16 | 48 | git-fast-import \ |
17 | | - openssh \ |
18 | | - && apk add --no-cache --virtual .build gcc musl-dev \ |
19 | | - && pip install --no-cache-dir -r requirements-free.txt \ |
20 | | - && apk del .build gcc musl-dev \ |
21 | | - && rm -rf /tmp/* |
| 49 | + openssh-client \ |
| 50 | + libffi \ |
| 51 | + musl-locales \ |
| 52 | + musl-locales-lang \ |
| 53 | + cairo \ |
| 54 | + pango \ |
| 55 | + gdk-pixbuf \ |
| 56 | + && echo "export LANG=fr_FR.UTF-8" > /etc/profile.d/locale.sh |
22 | 57 |
|
23 | | -# Set working directory |
24 | 58 | WORKDIR /app |
| 59 | + |
| 60 | +# Copy virtual environment from builder |
| 61 | +COPY --from=builder /opt/venv /opt/venv |
| 62 | + |
| 63 | +# Copy application files for initial setup |
| 64 | +COPY config/ ./config/ |
| 65 | +COPY hooks/ ./hooks/ |
| 66 | +COPY mkdocs.yml ./ |
| 67 | +COPY scripts/ ./scripts/ |
| 68 | + |
| 69 | +# Generate CLI help and merge config |
| 70 | +RUN mkdir -p content/toc_nav_ignored/snippets/code \ |
| 71 | + && geotribu --help > content/toc_nav_ignored/snippets/code/geotribu_cli_help.txt \ |
| 72 | + && python scripts/100_mkdocs_config_merger.py -c mkdocs.yml |
| 73 | + |
| 74 | +EXPOSE 8000 |
| 75 | + |
| 76 | +CMD ["mkdocs", "serve", "--dev-addr=0.0.0.0:8000"] |
0 commit comments