Skip to content

Commit a33bc8f

Browse files
Crash--claude
andcommitted
fix(docker): build cozy-stack directly without scripts/build.sh
scripts/build.sh derives the version from git describe / git rev-parse on the COPY'd working tree, which fails inside the buildx container (exit 128 with no captured output). Inline `go build` with a build-arg version string sidesteps the whole bash + git chain. The workflow passes VERSION_STRING=<tag>-<sha> so the running binary reports a recognizable version. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 53dd0aa commit a33bc8f

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

.github/workflows/docker-s3-test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,7 @@ jobs:
5555
tags: |
5656
${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.tag }}
5757
${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.sha_tag }}
58+
build-args: |
59+
VERSION_STRING=${{ steps.meta.outputs.tag }}-${{ github.sha }}
5860
cache-from: type=gha
5961
cache-to: type=gha,mode=max

scripts/docker/production/Dockerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ RUN go mod download
1414

1515
# Build cozy-stack
1616
COPY . .
17-
# scripts/build.sh runs `git describe` / `git rev-parse` to compute the
18-
# version string. When the working tree is COPY-ed into the container its
19-
# ownership no longer matches the host user, so recent git versions reject
20-
# operations on it ("detected dubious ownership"). Mark /app as safe so the
21-
# build step can read git metadata.
22-
RUN git config --global --add safe.directory /app \
23-
&& ./scripts/build.sh release ./cozy-stack
17+
# Build directly instead of going through scripts/build.sh, which runs
18+
# `git describe` / `git rev-parse` and trips on the COPY'd working tree
19+
# inside the container. The version string can be overridden at build
20+
# time via --build-arg VERSION_STRING=...
21+
ARG VERSION_STRING=docker-build
22+
RUN BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
23+
&& go build \
24+
-ldflags "-X github.com/cozy/cozy-stack/pkg/config.Version=${VERSION_STRING} \
25+
-X github.com/cozy/cozy-stack/pkg/config.BuildTime=${BUILD_TIME} \
26+
-X github.com/cozy/cozy-stack/pkg/config.BuildMode=production" \
27+
-o ./cozy-stack
2428

2529

2630
# Multi-stage image: the main image

0 commit comments

Comments
 (0)