Skip to content

feat: adopt mitodl/ol-python-base:3.12 and add BuildKit cache mounts#3447

Draft
blarghmatey wants to merge 1 commit into
mainfrom
tmacey/ol-python-base-image
Draft

feat: adopt mitodl/ol-python-base:3.12 and add BuildKit cache mounts#3447
blarghmatey wants to merge 1 commit into
mainfrom
tmacey/ol-python-base-image

Conversation

@blarghmatey

Copy link
Copy Markdown
Member

What are the relevant tickets?

N/A

Description (What does it do?)

⚠️ Draft — blocked on mitodl/ol-infrastructure#4750 merging and mitodl/ol-python-base:3.12 being published to DockerHub.

Adopts the new shared Python base image and adds BuildKit cache mounts to speed up cold-build and uv.lock-bump rebuilds in the Tilt/K3d local-dev environment.

Changes:

  • FROM mitodl/ol-python-base:3.12 replaces the four duplicated substrate stages (apt core, uv binary, mitodl user, /opt/venv env vars). The shared base is defined in https://github.com/mitodl/ol-infrastructure/tree/main/dockerfiles/ol-python-base.
  • App-specific apt (libcairo2-dev, poppler-utils, default-jre, chromium, chromium-driver) kept inline with --mount=type=cache for apt so downloaded packages are not baked into the image layer.
  • --mount=type=cache,target=/opt/uv-cache,uid=1000,gid=1000 on uv sync so uv.lock-bump rebuilds reuse the download cache across Tilt builds rather than re-downloading all wheels.
  • apt.txt trimmed to extras only; the common-core packages it previously listed are now in the base image.
  • Multi-stage structure preserved (base → deps → final).

Image size: 4.36 GB → 3.71 GB (−650 MB), which cuts the ~119s registry push proportionally.

How can this be tested?

After mitodl/ol-infrastructure#4750 merges and the Concourse pipeline publishes the base image:

# From the mit-learn repo root
DOCKER_BUILDKIT=1 docker build -t mitodl/mit-learn-app:test .
docker run --rm mitodl/mit-learn-app:test python --version
# Confirm uv sync cache reuse: touch uv.lock and rebuild — second build should
# skip all wheel downloads.

In the local-dev Tilt environment: tilt up mit-learn, confirm live_update still syncs Python source and triggers granian reload.

Additional Context

Part of a multi-repo series to eliminate duplicated Dockerfile substrate and speed up Tilt/K3d cold builds. Baseline: cold tilt up for mit-learn spent ~163s building and ~119s pushing its 4.36 GB image to the local k3d registry at localhost:5001. The shared base image (~590 MB) plus per-app layer slimming reduces both dimensions.

Merge order: ol-infrastructure PR first → Concourse pipeline registered → this PR can be merged.

- FROM mitodl/ol-python-base:3.12 replaces the duplicated substrate stages
  (apt core, uv binary, mitodl user, /opt/venv env vars).
- App-specific apt (libcairo2-dev, poppler-utils, default-jre, chromium,
  chromium-driver) kept inline with BuildKit --mount=type=cache for apt,
  keeping downloaded packages out of the image layer.
- BuildKit --mount=type=cache on uv sync so uv.lock-bump rebuilds reuse
  the download cache across Tilt builds (target=/opt/uv-cache uid=1000).
- apt.txt trimmed to extras only; common-core packages documented as
  living in the shared base image.
- Image size: 4.36 GB → 3.71 GB (-650 MB).
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

OpenAPI Changes

No changes detected

View full changelog

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant