diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c791e44ae7..4d881b43e0 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,7 +9,7 @@ // "image": "mcr.microsoft.com/devcontainers/python:0-3.11", // Features to add to the dev container. More info: https://containers.dev/features. "features": { - "ghcr.io/devcontainers-contrib/features/apt-packages:1": { + "ghcr.io/devcontainers-extra/features/apt-packages:1": { "packages": [ "libcairo2-dev", "libfreetype6-dev", @@ -20,7 +20,7 @@ "pngquant" ] }, - "ghcr.io/devcontainers-contrib/features/coverage-py:2": {} + "ghcr.io/devcontainers-extra/features/coverage-py:2": {} }, // Configure tool-specific properties. "customizations": { @@ -80,7 +80,7 @@ "tag:yaml.org,2002:python/name:pymdownx.superfences.fence_code_format", "tag:yaml.org,2002:python/name:material.plugins.tags.casefold", "tag:yaml.org,2002:python/name:material.plugins.tags.page_url" - ], + ] }, "extensions": [ "bierner.markdown-mermaid", diff --git a/Dockerfile b/Dockerfile index ef69b85788..9217e8aae0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,76 @@ -FROM python:3.11-alpine +# == Builder Stage: Install dependencies with build tools == +FROM python:3.12-alpine AS builder -ENV PYTHONDONTWRITEBYTECODE 1 -ENV PYTHONUNBUFFERED 1 +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + PIP_NO_CACHE_DIR=1 \ + PIP_DISABLE_PIP_VERSION_CHECK=1 -# Set build directory -WORKDIR /tmp +WORKDIR /build -# Install pip requirements -ADD requirements*.txt ./ +# Install build dependencies +RUN apk add --no-cache \ + gcc \ + musl-dev \ + libffi-dev \ + openssl-dev \ + cairo-dev \ + pango-dev \ + gdk-pixbuf-dev -# Perform build and cleanup artifacts -RUN \ - apk add --no-cache \ +# Copy and install Python dependencies +COPY requirements.txt ./ +RUN python -m venv /opt/venv \ + && /opt/venv/bin/pip install --upgrade pip \ + && /opt/venv/bin/pip install -r requirements.txt + + +# == Runtime Stage: Minimal image for development == + +FROM python:3.12-alpine + +LABEL org.opencontainers.image.title="Geotribu Website Stack" \ + org.opencontainers.image.description="Technical stack to build Geotribu website." \ + org.opencontainers.image.source="https://github.com/geotribu/website/" \ + org.opencontainers.image.licenses="GPL-3.0-or-later" + +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + PYTHONOPTIMIZE=2 \ + LANG=fr_FR.UTF-8 \ + LANGUAGE=fr_FR:fr \ + LC_ALL=fr_FR.UTF-8 \ + PATH="/opt/venv/bin:$PATH" + +# Install runtime dependencies including French locale support +RUN apk add --no-cache \ git \ git-fast-import \ - openssh \ - && apk add --no-cache --virtual .build gcc musl-dev \ - && pip install --no-cache-dir -r requirements-free.txt \ - && apk del .build gcc musl-dev \ - && rm -rf /tmp/* + openssh-client \ + libffi \ + musl-locales \ + musl-locales-lang \ + cairo \ + pango \ + gdk-pixbuf \ + && echo "export LANG=fr_FR.UTF-8" > /etc/profile.d/locale.sh -# Set working directory WORKDIR /app + +# Copy virtual environment from builder +COPY --from=builder /opt/venv /opt/venv + +# Copy application files for initial setup +COPY config/ ./config/ +COPY hooks/ ./hooks/ +COPY mkdocs.yml ./ +COPY scripts/ ./scripts/ + +# Generate CLI help and merge config +RUN mkdir -p content/toc_nav_ignored/snippets/code \ + && geotribu --help > content/toc_nav_ignored/snippets/code/geotribu_cli_help.txt \ + && python scripts/100_mkdocs_config_merger.py -c mkdocs.yml + +EXPOSE 8000 + +CMD ["mkdocs", "serve", "--dev-addr=0.0.0.0:8000"] diff --git a/docker-compose-mkdocs.dev.yml b/docker-compose-mkdocs.dev.yml index ed802ad842..63465c63c8 100644 --- a/docker-compose-mkdocs.dev.yml +++ b/docker-compose-mkdocs.dev.yml @@ -1,5 +1,3 @@ -version: '3.7' - services: website: container_name: geotribu-mkdocs-site @@ -12,5 +10,5 @@ services: ports: - 8000:8000 volumes: - - .:/app - command: mkdocs serve --config-file mkdocs-minimal.yml --dirtyreload --dev-addr=0.0.0.0:8000 + - ./content/:/app + command: mkdocs serve --dirtyreload --dev-addr=0.0.0.0:8000