build: don't use context for building Docker image

Use a provided VERSION argument to override the one in the Makefile.
This commit is contained in:
Vincent Bernat
2025-08-04 12:26:27 +02:00
parent 04b9fbde5e
commit 83261a453d
3 changed files with 10 additions and 3 deletions

View File

@@ -238,6 +238,10 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
persist-credentials: false persist-credentials: false
- name: Get version
id: version
run: |
echo version=$(make version) >> "$GITHUB_OUTPUT"
- uses: docker/setup-qemu-action@v3 - uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3 - uses: docker/setup-buildx-action@v3
- uses: docker/metadata-action@v5 - uses: docker/metadata-action@v5
@@ -256,9 +260,9 @@ jobs:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6 - name: Build image
uses: docker/build-push-action@v6
with: with:
context: .
file: docker/Dockerfile file: docker/Dockerfile
platforms: | platforms: |
linux/amd64 linux/amd64
@@ -266,6 +270,8 @@ jobs:
linux/arm64 linux/arm64
linux/arm/v7 linux/arm/v7
push: true push: true
build-args: |
VERSION=${{ steps.version.outputs.version }}
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }} annotations: ${{ steps.meta.outputs.annotations }}

View File

@@ -18,6 +18,7 @@ RUN touch console/frontend/node_modules console/data/frontend .fmt-js~ .fmt.go~
ARG TARGETOS ARG TARGETOS
ARG TARGETARCH ARG TARGETARCH
ARG TARGETVARIANT ARG TARGETVARIANT
ARG VERSION
RUN make RUN make
FROM gcr.io/distroless/static:latest FROM gcr.io/distroless/static:latest

View File

@@ -4,7 +4,7 @@ RUN echo filter-syscalls = false >> /etc/nix/nix.conf
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN mkdir -p /output/store RUN mkdir -p /output/store
RUN git describe --tags --always --dirty --match=v* > .version && git add -f .version RUN make version > .version && git add -f .version
RUN nix run ".#update" \ RUN nix run ".#update" \
&& nix run ".#build" \ && nix run ".#build" \
&& cp -va $(nix-store -qR result) /output/store \ && cp -va $(nix-store -qR result) /output/store \