|
1 | | -FROM python:3.11-slim |
| 1 | +FROM python:3.13-slim |
2 | 2 |
|
3 | | -# Write .pyc files only once. See: https://stackoverflow.com/a/60797635/2556577 |
4 | | -ENV PYTHONDONTWRITEBYTECODE 1 |
5 | | -# Make sure that stdout and stderr are not buffered. See: https://stackoverflow.com/a/59812588/2556577 |
6 | | -ENV PYTHONUNBUFFERED 1 |
7 | | -# Remove assert statements and any code conditional on __debug__. See: https://docs.python.org/3/using/cmdline.html#cmdoption-O |
8 | | -ENV PYTHONOPTIMIZE 2 |
| 3 | +# Avoid .pyc bytecode and ensure output is unbuffered for CLI responsiveness |
| 4 | +ENV PYTHONDONTWRITEBYTECODE=1 \ |
| 5 | + PYTHONUNBUFFERED=1 \ |
| 6 | + PYTHONOPTIMIZE=2 |
9 | 7 |
|
10 | | -WORKDIR /user/app |
| 8 | +# Add user's local bin directory to PATH for pip installed packages |
| 9 | +ENV PATH="/home/geotribuser/.local/bin:$PATH" |
11 | 10 |
|
12 | | -COPY requirements.txt . |
13 | | -COPY requirements/base.txt ./requirements/ |
| 11 | +# Set locale to French UTF-8 |
| 12 | +RUN apt update && \ |
| 13 | + apt install -y --no-install-recommends locales && \ |
| 14 | + echo "fr_FR.UTF-8 UTF-8" > /etc/locale.gen && \ |
| 15 | + locale-gen \ |
| 16 | + && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* |
14 | 17 |
|
15 | | -RUN python -m pip install --no-cache-dir -U pip && \ |
16 | | - python -m pip install --no-cache-dir -U setuptools wheel |
| 18 | +ENV LANG=fr_FR.UTF-8 \ |
| 19 | + LANGUAGE=fr_FR:fr \ |
| 20 | + LC_ALL=fr_FR.UTF-8 |
17 | 21 |
|
18 | | -COPY . . |
| 22 | +# Create non-root group and user dedicated to geotribu usage |
| 23 | +RUN groupadd --system geotribu && \ |
| 24 | + useradd -m -s /bin/bash -g geotribu geotribuser |
19 | 25 |
|
20 | | -RUN python -m pip install -U --no-cache-dir -r requirements.txt |
| 26 | +USER geotribuser |
21 | 27 |
|
22 | | -RUN python -m pip install -U -e . |
| 28 | +# Set working directory and proper permissions |
| 29 | +WORKDIR /home/geotribuser |
23 | 30 |
|
24 | | -CMD ["bash"] |
| 31 | +# Custom CLI settings |
| 32 | +ENV GEOTRIBU_CACHE_EXPIRATION_HOURS=240 \ |
| 33 | + GEOTRIBU_COMMENTS_EXPIRATION_HOURS=240 \ |
| 34 | + GEOTRIBU_RESULTATS_FORMAT=table \ |
| 35 | + GEOTRIBU_RESULTATS_NOMBRE=20 |
| 36 | + |
| 37 | +COPY --chown=geotribuser:geotribu . . |
| 38 | + |
| 39 | +RUN pip install --no-cache-dir .[all] \ |
| 40 | + && rm -rf ~/.cache/pip \ |
| 41 | + && geotribu sc --no-prompt "qgis" \ |
| 42 | + && geotribu si --no-prompt "qgis" \ |
| 43 | + && geotribu comments latest |
| 44 | + |
| 45 | +ENTRYPOINT ["geotribu"] |
| 46 | +CMD [] |
0 commit comments