Skip to content

Commit ae84c25

Browse files
committed
Dockerfile: merge build stages
Signed-off-by: CrazyMax <[email protected]>
1 parent 2adf3cf commit ae84c25

File tree

1 file changed

+20
-36
lines changed

1 file changed

+20
-36
lines changed

Dockerfile

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG GO_VERSION=1.24.7
44
ARG DEBIAN_VERSION=bookworm
55

66
ARG XX_VERSION=1.7.0
7-
ARG OSXCROSS_VERSION=11.3-r7-debian
7+
ARG OSXCROSS_VERSION=11.3-r8-debian
88
ARG GOLANGCI_LINT_VERSION=v2.5
99
ARG DEBIAN_FRONTEND=noninteractive
1010

@@ -99,21 +99,7 @@ FROM gobase AS version
9999
RUN --mount=target=. \
100100
echo -n "$(./hack/git-meta version)" | tee /tmp/.version ; echo -n "$(./hack/git-meta revision)" | tee /tmp/.revision
101101

102-
FROM base AS build-linux
103-
ARG PACKAGE
104-
RUN --mount=type=bind,target=. \
105-
--mount=type=cache,target=/root/.cache \
106-
--mount=type=cache,target=/go/pkg/mod \
107-
--mount=type=bind,source=/tmp/.version,target=/tmp/.version,from=version \
108-
--mount=type=bind,source=/tmp/.revision,target=/tmp/.revision,from=version <<EOT
109-
set -ex
110-
xx-go --wrap
111-
make build-pass build-secretservice PACKAGE=$PACKAGE VERSION=$(cat /tmp/.version) REVISION=$(cat /tmp/.revision) DESTDIR=/out
112-
xx-verify /out/docker-credential-pass
113-
xx-verify /out/docker-credential-secretservice
114-
EOT
115-
116-
FROM base AS build-darwin
102+
FROM base AS build
117103
ARG PACKAGE
118104
RUN --mount=type=bind,target=. \
119105
--mount=type=cache,target=/root/.cache \
@@ -124,28 +110,26 @@ RUN --mount=type=bind,target=. \
124110
set -ex
125111
export MACOSX_VERSION_MIN=$(make print-MACOSX_DEPLOYMENT_TARGET)
126112
xx-go --wrap
127-
go install std
128-
make build-osxkeychain build-pass PACKAGE=$PACKAGE VERSION=$(cat /tmp/.version) REVISION=$(cat /tmp/.revision) DESTDIR=/out
129-
xx-verify /out/docker-credential-osxkeychain
130-
xx-verify /out/docker-credential-pass
113+
case "$(xx-info os)" in
114+
linux)
115+
make build-pass build-secretservice PACKAGE=$PACKAGE VERSION=$(cat /tmp/.version) REVISION=$(cat /tmp/.revision) DESTDIR=/out
116+
xx-verify /out/docker-credential-pass
117+
xx-verify /out/docker-credential-secretservice
118+
;;
119+
darwin)
120+
go install std
121+
make build-osxkeychain build-pass PACKAGE=$PACKAGE VERSION=$(cat /tmp/.version) REVISION=$(cat /tmp/.revision) DESTDIR=/out
122+
xx-verify /out/docker-credential-osxkeychain
123+
xx-verify /out/docker-credential-pass
124+
;;
125+
windows)
126+
make build-wincred PACKAGE=$PACKAGE VERSION=$(cat /tmp/.version) REVISION=$(cat /tmp/.revision) DESTDIR=/out
127+
mv /out/docker-credential-wincred /out/docker-credential-wincred.exe
128+
xx-verify /out/docker-credential-wincred.exe
129+
;;
130+
esac
131131
EOT
132132

133-
FROM base AS build-windows
134-
ARG PACKAGE
135-
RUN --mount=type=bind,target=. \
136-
--mount=type=cache,target=/root/.cache \
137-
--mount=type=cache,target=/go/pkg/mod \
138-
--mount=type=bind,source=/tmp/.version,target=/tmp/.version,from=version \
139-
--mount=type=bind,source=/tmp/.revision,target=/tmp/.revision,from=version <<EOT
140-
set -ex
141-
xx-go --wrap
142-
make build-wincred PACKAGE=$PACKAGE VERSION=$(cat /tmp/.version) REVISION=$(cat /tmp/.revision) DESTDIR=/out
143-
mv /out/docker-credential-wincred /out/docker-credential-wincred.exe
144-
xx-verify /out/docker-credential-wincred.exe
145-
EOT
146-
147-
FROM build-$TARGETOS AS build
148-
149133
FROM scratch AS binaries
150134
COPY --from=build /out /
151135

0 commit comments

Comments
 (0)