Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update codespell Docker image definition #1723

Merged
merged 14 commits into from
Feb 13, 2025
Merged
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
.tools/
**/internal/test/e2e/*/main

# Python pip cache.
.cache/

# Test binary, built with `go test -c`
*.test

Expand Down
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export BPF2GO_CFLAGS
GOCMD?= go
CGO_ENABLED?=0

# User to run as in docker images.
DOCKER_USER=$(shell id -u):$(shell id -g)
DEPENDENCIES_DOCKERFILE=./dependencies.Dockerfile

.DEFAULT_GOAL := precommit

.PHONY: precommit
Expand Down Expand Up @@ -249,11 +253,8 @@ PIP := $(PYTOOLS)/pip
# The directory in the docker image where the current directory is mounted.
WORKDIR := /workdir

# Ensure correct ownership.
DOCKER_USER=$(shell id -u):$(shell id -g)

# The python image to use for the virtual environment.
PYTHONIMAGE := python:3.11.3-slim-bullseye
PYTHONIMAGE := $(shell awk '$$4=="python" {print $$2}' $(DEPENDENCIES_DOCKERFILE))

# Run the python image with the current directory mounted.
DOCKERPY := docker run --rm -u $(DOCKER_USER) -v "$(CURDIR):$(WORKDIR)" -w $(WORKDIR) $(PYTHONIMAGE)
Expand All @@ -262,11 +263,11 @@ DOCKERPY := docker run --rm -u $(DOCKER_USER) -v "$(CURDIR):$(WORKDIR)" -w $(WOR
$(PYTOOLS):
# The `--upgrade` flag is needed to ensure that the virtual environment is
# created with the latest pip version.
@$(DOCKERPY) bash -c "python3 -m venv $(VENVDIR) && $(PIP) install --upgrade pip"
@$(DOCKERPY) bash -c "python3 -m venv $(VENVDIR) && $(PIP) install --upgrade --cache-dir=$(WORKDIR)/.cache/pip pip"

# Install python packages into the virtual environment.
$(PYTOOLS)/%: $(PYTOOLS)
@$(DOCKERPY) $(PIP) install -r requirements.txt
@$(DOCKERPY) $(PIP) install --cache-dir=$(WORKDIR)/.cache/pip -r requirements.txt

CODESPELL = $(PYTOOLS)/codespell
$(CODESPELL): PACKAGE=codespell
Expand Down
2 changes: 2 additions & 0 deletions dependencies.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This is a renovate-friendly source of Docker images.
FROM python:3.13.1-slim-bullseye AS python
Loading