build: fix make release-docker (#918)

PR
- https://github.com/zrepl/zrepl/pull/913

didn't update the `release-docker` flow to use `uv`, thereby breaking
it.

## Changes

- Create `.uv-version` file to centralize UV version between Dockerfile
and CircleCI
- Update build container to use `uv`

While at it, make life with the build container better:
- Create `zrepl_build` user in the build container as same UID/GID as
the caller of `make release-docker`
- Allow Ctrl-C to cancel `make release-docker` in interactive shells
This commit is contained in:
Christian Schwarz
2026-02-10 19:13:03 +01:00
committed by GitHub
parent 888283c06f
commit ed4547166a
4 changed files with 37 additions and 20 deletions
+10 -5
View File
@@ -16,14 +16,19 @@ commands:
echo "$line" >> $BASH_ENV echo "$line" >> $BASH_ENV
fi fi
# NOTE: when updating uv version, update both the install URL and cache keys below # NOTE: UV version is defined in .uv-version file at repository root
install-docdep: install-docdep:
steps: steps:
- run:
name: Read UV version from .uv-version
command: |
UV_VERSION=$(cat .uv-version)
echo "export UV_VERSION=$UV_VERSION" >> $BASH_ENV
# Python is managed by uv - it will automatically download the version # Python is managed by uv - it will automatically download the version
# specified in docs/.python-version when needed # specified in docs/.python-version when needed
- run: - run:
name: Install uv name: Install uv
command: curl -LsSf https://astral.sh/uv/0.9.30/install.sh | sh command: curl -LsSf https://astral.sh/uv/${UV_VERSION}/install.sh | sh
- run: - run:
name: Add uv to PATH and set cache dir name: Add uv to PATH and set cache dir
command: | command: |
@@ -32,8 +37,8 @@ commands:
- restore_cache: - restore_cache:
name: Restore uv cache name: Restore uv cache
keys: keys:
- uv-cache-v1-0.9.30-{{ checksum "docs/uv.lock" }} - uv-cache-v1-${UV_VERSION}-{{ checksum "docs/uv.lock" }}
- uv-cache-v1-0.9.30- - uv-cache-v1-${UV_VERSION}-
save-uv-cache: save-uv-cache:
steps: steps:
@@ -42,7 +47,7 @@ commands:
command: uv cache prune --ci command: uv cache prune --ci
- save_cache: - save_cache:
name: Save uv cache name: Save uv cache
key: uv-cache-v1-0.9.30-{{ checksum "docs/uv.lock" }} key: uv-cache-v1-${UV_VERSION}-{{ checksum "docs/uv.lock" }}
paths: paths:
- ~/.cache/uv - ~/.cache/uv
+1
View File
@@ -0,0 +1 @@
0.9.30
+7 -4
View File
@@ -42,7 +42,7 @@ endif
ifneq ($(RELEASE_DOCKER_CACHEMOUNT),) ifneq ($(RELEASE_DOCKER_CACHEMOUNT),)
_RELEASE_DOCKER_CACHEMOUNT := -v $(RELEASE_DOCKER_CACHEMOUNT)/mod:/go/pkg/mod -v $(RELEASE_DOCKER_CACHEMOUNT)/xdg-cache:/root/.cache/go-build _RELEASE_DOCKER_CACHEMOUNT := -v $(RELEASE_DOCKER_CACHEMOUNT)/mod:/go/pkg/mod -v $(RELEASE_DOCKER_CACHEMOUNT)/xdg-cache:/.cache/go-build
.PHONY: release-docker-mkcachemount .PHONY: release-docker-mkcachemount
release-docker-mkcachemount: release-docker-mkcachemount:
mkdir -p $(RELEASE_DOCKER_CACHEMOUNT) mkdir -p $(RELEASE_DOCKER_CACHEMOUNT)
@@ -71,10 +71,13 @@ release: ensure-release-toolchain
release-docker: $(ARTIFACTDIR) release-docker-mkcachemount release-docker: $(ARTIFACTDIR) release-docker-mkcachemount
sed 's/FROM.*!SUBSTITUTED_BY_MAKEFILE/FROM $(RELEASE_DOCKER_BASEIMAGE)/' build/build.Dockerfile > $(ARTIFACTDIR)/build.Dockerfile sed 's/FROM.*!SUBSTITUTED_BY_MAKEFILE/FROM $(RELEASE_DOCKER_BASEIMAGE)/' build/build.Dockerfile > $(ARTIFACTDIR)/build.Dockerfile
docker build -t zrepl_release --pull -f $(ARTIFACTDIR)/build.Dockerfile . docker build -t zrepl_release --pull \
docker run --rm -i \ --build-arg BUILD_UID=$$(id -u) \
--build-arg BUILD_GID=$$(id -g) \
-f $(ARTIFACTDIR)/build.Dockerfile .
docker run --rm -i$$(test -t 0 && echo t) \
$(_RELEASE_DOCKER_CACHEMOUNT) \ $(_RELEASE_DOCKER_CACHEMOUNT) \
-v $(CURDIR):/src -u $$(id -u):$$(id -g) \ -v $(CURDIR):/src \
zrepl_release \ zrepl_release \
make release \ make release \
GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \ GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \
+19 -11
View File
@@ -1,22 +1,30 @@
FROM !SUBSTITUTED_BY_MAKEFILE FROM !SUBSTITUTED_BY_MAKEFILE
RUN apt-get update && apt-get install -y \ ARG BUILD_UID=1000
python3-pip \ ARG BUILD_GID=1000
python3-venv \
unzip \
gawk
# setup venv for docs RUN apt-get update && apt-get install -y \
ENV VIRTUAL_ENV=/opt/venv python3 \
RUN python3 -m venv $VIRTUAL_ENV unzip \
ENV PATH="$VIRTUAL_ENV/bin:$PATH" gawk \
ADD docs/requirements.txt /tmp/requirements.txt curl
RUN pip3 install -r /tmp/requirements.txt
# Create build user with the host's UID/GID before installing uv
RUN groupadd -g ${BUILD_GID} zrepl_build && \
useradd -u ${BUILD_UID} -g ${BUILD_GID} -m zrepl_build
# Go toolchain uses xdg-cache # Go toolchain uses xdg-cache
RUN mkdir -p /.cache && chmod -R 0777 /.cache RUN mkdir -p /.cache && chmod -R 0777 /.cache
# Install uv as the build user - version from .uv-version file
ADD .uv-version /tmp/.uv-version
USER zrepl_build
RUN UV_VERSION=$(cat /tmp/.uv-version) && \
curl -LsSf https://astral.sh/uv/${UV_VERSION}/install.sh | sh
# Go devtools are managed by Makefile # Go devtools are managed by Makefile
WORKDIR /src WORKDIR /src
ENV PATH="/home/zrepl_build/.local/bin:$PATH" \
GOCACHE="/.cache/go-build"