Skip to content

Commit cc86862

Browse files
committed
update python
1 parent 8813bdb commit cc86862

File tree

2 files changed

+47
-10
lines changed

2 files changed

+47
-10
lines changed

.dockerignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# VCS
2+
.git
3+
4+
# Python caches
5+
__pycache__
6+
**/__pycache__
7+
*.pyc
8+
*.pyo
9+
*.pyd
10+
11+
# Virtual envs
12+
.venv
13+
venv/
14+
ENV/
15+
16+
# Tool caches
17+
.ruff_cache
18+
.pytest_cache
19+
.mypy_cache
20+
21+
# Editors/IDE
22+
.vscode
23+
.idea
24+
25+
# OS junk
26+
.DS_Store
27+
Thumbs.db

Dockerfile

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
11
FROM hexletbasics/base-image
22

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
85

9-
# Update PATH
10-
ENV PATH="/root/.local/bin:${PATH}"
6+
# Keep project bin in PATH (existing convention)
117
ENV PATH="/exercises-python/bin:${PATH}"
128

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}
1422

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}
1626

1727
WORKDIR /exercises-python
1828

29+
# Cache dependencies: copy manifests first, sync, then copy the rest
1930
COPY pyproject.toml uv.lock ./
20-
2131
RUN uv sync --locked
2232

2333
COPY . .

0 commit comments

Comments
 (0)