|
| 1 | +# Use the specified base image |
1 | 2 | FROM ghcr.io/geocompx/minimal |
2 | 3 |
|
3 | | -# Use Python already provisioned by the base image virtualenv (/opt/venv). |
4 | | -# Do not reinstall Python; ensure the venv python is preferred and 'python' exists. |
5 | | -RUN /rocker_scripts/install_python.sh |
| 4 | +# Install core Python 3 packages and other dependencies. |
| 5 | +# - python3-dev: Headers needed to compile certain Python packages with C extensions. |
| 6 | +# - python3-pip: The package installer for Python 3, installed globally. |
| 7 | +# - swig: Used for wrapping C/C++ libraries for Python. |
| 8 | +# - python3-venv: The module to create virtual environments. |
| 9 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 10 | + python3 \ |
| 11 | + python3-dev \ |
| 12 | + python3-pip \ |
| 13 | + python3-venv \ |
| 14 | + swig && \ |
| 15 | + rm -rf /var/lib/apt/lists/* |
6 | 16 |
|
7 | | -# Prefer the venv python and put its bin on PATH so reticulate picks it up. |
8 | | -ENV RETICULATE_PYTHON=/opt/venv/bin/python |
9 | | -ENV PATH=/opt/venv/bin:${PATH} |
| 17 | +# Create a symbolic link so the 'python' command defaults to 'python3' |
| 18 | +# The '-f' flag forces the creation of the symbolic link, overwriting any existing file. |
| 19 | +RUN ln -sf /usr/bin/python3 /usr/bin/python |
10 | 20 |
|
11 | | -# Override the python symlink to use the venv Python (not system Python) |
12 | | -RUN ln -sf /opt/venv/bin/python /usr/bin/python |
13 | | -RUN ln -sf /opt/venv/bin/python /bin/python |
| 21 | +# Create a symbolic link so the 'pip' command defaults to 'pip3' |
| 22 | +# The '-f' flag forces the creation of the symbolic link, overwriting any existing file. |
| 23 | +RUN ln -sf /usr/bin/pip3 /usr/bin/pip |
14 | 24 |
|
15 | | -# Set version of Python that Quarto will use: |
| 25 | +# Create a Python virtual environment to avoid system package conflicts. |
| 26 | +RUN python3 -m venv /opt/venv |
| 27 | + |
| 28 | +# Set the environment variable for Quarto to use the virtual environment's Python. |
16 | 29 | ENV QUARTO_PYTHON=/opt/venv/bin/python |
17 | 30 |
|
18 | | -# Optionally install project requirements into the existing venv if desired: |
19 | | -RUN /opt/venv/bin/pip install -r https://github.com/geocompx/geocompy/raw/refs/heads/main/requirements.txt |
| 31 | +# Add the virtual environment's bin directory to the PATH. |
| 32 | +ENV PATH="/opt/venv/bin:$PATH" |
| 33 | + |
| 34 | +# Install project requirements into the virtual environment. |
| 35 | +# This avoids all system package conflicts. |
| 36 | +RUN pip install --no-cache-dir -r https://github.com/geocompx/geocompy/raw/refs/heads/main/requirements.txt |
| 37 | + |
| 38 | +# Install reticulate R package to enable R-Python interoperability |
| 39 | +# This step remains the same as it is a separate R installation. |
| 40 | +RUN R -e "install.packages('reticulate', repos='https://cloud.r-project.org/')" |
0 commit comments