|
1 | 1 | FROM hexletbasics/base-image |
2 | 2 |
|
3 | | -# Install pipx using apt to avoid externally-managed Python issues |
4 | | -RUN apt-get update && apt-get install -y pipx \ |
5 | | - && pipx ensurepath \ |
6 | | - && apt-get clean \ |
7 | | - && rm -rf /var/lib/apt/lists/* |
| 3 | +# Configure versions and paths up front for better caching |
| 4 | +ARG PYTHON_VERSION=3.14 |
8 | 5 |
|
9 | | -# Update PATH |
10 | | -ENV PATH="/root/.local/bin:${PATH}" |
| 6 | +# Keep project bin in PATH (existing convention) |
11 | 7 | ENV PATH="/exercises-python/bin:${PATH}" |
12 | 8 |
|
13 | | -RUN pipx install uv |
| 9 | +# Install curl and CA certs (minimal), then install uv via official script |
| 10 | +ENV UV_INSTALL_DIR=/opt/uv |
| 11 | +ENV PATH="${UV_INSTALL_DIR}/bin:${PATH}" |
| 12 | +RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates \ |
| 13 | + && apt-get clean \ |
| 14 | + && rm -rf /var/lib/apt/lists/* \ |
| 15 | + && curl -fsSL https://astral.sh/uv/install.sh | sh \ |
| 16 | + && ln -s ${UV_INSTALL_DIR}/* /usr/local/bin/ |
| 17 | + |
| 18 | +# Create a dedicated virtualenv managed by uv with the requested Python |
| 19 | +ENV VIRTUAL_ENV=/opt/venv |
| 20 | +ENV UV_PYTHON_INSTALL_DIR=${VIRTUAL_ENV} |
| 21 | +RUN uv venv --allow-existing ${VIRTUAL_ENV} --python ${PYTHON_VERSION} |
14 | 22 |
|
15 | | -ENV UV_PROJECT_ENVIRONMENT=/usr |
| 23 | +# Activate venv for subsequent steps and point uv to it for project deps |
| 24 | +ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" |
| 25 | +ENV UV_PROJECT_ENVIRONMENT=${VIRTUAL_ENV} |
16 | 26 |
|
17 | 27 | WORKDIR /exercises-python |
18 | 28 |
|
| 29 | +# Cache dependencies: copy manifests first, sync, then copy the rest |
19 | 30 | COPY pyproject.toml uv.lock ./ |
20 | | - |
21 | 31 | RUN uv sync --locked |
22 | 32 |
|
23 | 33 | COPY . . |
|
0 commit comments