Skip to content

Commit 1ee061d

Browse files
committedOct 10, 2024
chore: only use Docker to build docker-runx
Signed-off-by: Yves Brissaud <[email protected]>
1 parent e1b35a4 commit 1ee061d

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed
 

‎Dockerfile

+12-10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ FROM build AS binary
3030
ARG TARGETOS
3131
ARG TARGETARCH
3232
ARG BIN_NAME
33+
ARG NO_ARCHIVE
3334
ENV CGO_ENABLED=0
3435
RUN --mount=type=cache,target=/root/.cache \
3536
--mount=type=cache,target=/go/pkg/mod \
@@ -41,19 +42,20 @@ RUN --mount=type=cache,target=/root/.cache \
4142
-X $PKG_NAME/internal/constants.Version=$GIT_VERSION" \
4243
./cmd/${BIN_NAME} && \
4344
xx-verify dist/${BIN_NAME} && \
44-
# on windows add the .exe extension and zip the binary \
45-
if [ "${TARGETOS}" = "windows" ]; then \
46-
mv dist/${BIN_NAME} dist/${BIN_NAME}.exe && \
47-
cd dist && zip ${BIN_NAME}-${TARGETOS}-${TARGETARCH}.zip ${BIN_NAME}.exe; \
48-
fi && \
49-
# if target os is not windows, tar and gzip the binary \
50-
if [ "${TARGETOS}" != "windows" ]; then \
51-
tar -C dist -czf dist/${BIN_NAME}-${TARGETOS}-${TARGETARCH}.tar.gz ${BIN_NAME}; \
45+
if [ -z "${NO_ARCHIVE}" ]; then \
46+
# on windows add the .exe extension and zip the binary \
47+
if [ "${TARGETOS}" = "windows" ]; then \
48+
mv dist/${BIN_NAME} dist/${BIN_NAME}.exe && \
49+
(cd dist && zip ${BIN_NAME}-${TARGETOS}-${TARGETARCH}.zip ${BIN_NAME}.exe && rm -f ${BIN_NAME}.exe); \
50+
fi && \
51+
# if target os is not windows, tar and gzip the binary \
52+
if [ "${TARGETOS}" != "windows" ]; then \
53+
tar -C dist -czf dist/${BIN_NAME}-${TARGETOS}-${TARGETARCH}.tar.gz ${BIN_NAME} && rm -f dist/${BIN_NAME}; \
54+
fi \
5255
fi
5356

5457
FROM scratch AS export-bin
5558
ARG BIN_NAME
5659
ARG TARGETOS
5760
ARG TARGETARCH
58-
COPY --from=binary /go/src/dist/*.zip /
59-
COPY --from=binary /go/src/dist/*.tar.gz /
61+
COPY --from=binary /go/src/dist/* /

‎Taskfile.yaml

+8-10
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@ tasks:
3232
go:bin:
3333
cmds:
3434
- |
35-
go build \
36-
-o dist/{{.BIN_NAME}} \
37-
-ldflags="-w -s \
38-
-X '{{.PKG_NAME}}/internal/constants.Version={{.VERSION}}'" \
39-
./cmd/{{.BIN_NAME}}
40-
env:
41-
CGO_ENABLED: 0
42-
vars:
43-
VERSION:
44-
sh: git describe --tags | cut -c 2-
35+
docker buildx build \
36+
--build-arg BIN_NAME={{.BIN_NAME}} \
37+
--build-arg NO_ARCHIVE=true \
38+
-f Dockerfile \
39+
--platform local \
40+
--target export-bin \
41+
-o type=local,dest=dist,platform-split=false \
42+
.
4543
4644
go:bin:all:
4745
cmds:

0 commit comments

Comments
 (0)
Please sign in to comment.