@@ -11,6 +11,10 @@ ALL_COVERAGE_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {}
11
11
GO = go
12
12
TIMEOUT = 60
13
13
14
+ # User to run as in docker images.
15
+ DOCKER_USER =$(shell id -u) :$(shell id -g)
16
+ DEPENDENCIES_DOCKERFILE =./dependencies.Dockerfile
17
+
14
18
.DEFAULT_GOAL := precommit
15
19
16
20
.PHONY : precommit ci
@@ -81,20 +85,20 @@ PIP := $(PYTOOLS)/pip
81
85
WORKDIR := /workdir
82
86
83
87
# 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 ) )
85
89
86
90
# 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 )
88
92
89
93
# Create a virtual environment for Python tools.
90
94
$(PYTOOLS ) :
91
95
# The `--upgrade` flag is needed to ensure that the virtual environment is
92
96
# 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"
94
98
95
99
# Install python packages into the virtual environment.
96
100
$(PYTOOLS ) /% : $(PYTOOLS )
97
- @$(DOCKERPY ) $(PIP ) install -r requirements.txt
101
+ @$(DOCKERPY ) $(PIP ) install --cache-dir= $( WORKDIR ) /.cache/pip - r requirements.txt
98
102
99
103
CODESPELL = $(PYTOOLS ) /codespell
100
104
$(CODESPELL ) : PACKAGE=codespell
0 commit comments