Skip to content

Commit d29d8ec

Browse files
committed
Update codespell target
Use the local user to install and run so that root does not own the artifacts. Move the python image into a place renovate can maintain it.
1 parent a027f11 commit d29d8ec

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
Thumbs.db
33

4+
.cache/
45
.tools/
56
venv/
67
.idea/

Makefile

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ ALL_COVERAGE_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {}
1111
GO = go
1212
TIMEOUT = 60
1313

14+
# User to run as in docker images.
15+
DOCKER_USER=$(shell id -u):$(shell id -g)
16+
DEPENDENCIES_DOCKERFILE=./dependencies.Dockerfile
17+
1418
.DEFAULT_GOAL := precommit
1519

1620
.PHONY: precommit ci
@@ -81,20 +85,20 @@ PIP := $(PYTOOLS)/pip
8185
WORKDIR := /workdir
8286

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

8690
# Run the python image with the current directory mounted.
87-
DOCKERPY := docker run --rm -v "$(CURDIR):$(WORKDIR)" -w $(WORKDIR) $(PYTHONIMAGE)
91+
DOCKERPY := docker run --rm -u $(DOCKER_USER) -v "$(CURDIR):$(WORKDIR)" -w $(WORKDIR) $(PYTHONIMAGE)
8892

8993
# Create a virtual environment for Python tools.
9094
$(PYTOOLS):
9195
# The `--upgrade` flag is needed to ensure that the virtual environment is
9296
# created with the latest pip version.
93-
@$(DOCKERPY) bash -c "python3 -m venv $(VENVDIR) && $(PIP) install --upgrade pip"
97+
@$(DOCKERPY) bash -c "python3 -m venv $(VENVDIR) && $(PIP) install --upgrade --cache-dir=$(WORKDIR)/.cache/pip pip"
9498

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

99103
CODESPELL = $(PYTOOLS)/codespell
100104
$(CODESPELL): PACKAGE=codespell

dependencies.Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This is a renovate-friendly source of Docker images.
2+
FROM python:3.13.1-slim-bullseye AS python

0 commit comments

Comments
 (0)