-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathDockerfile
49 lines (38 loc) · 1.37 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# syntax=docker/dockerfile:1.5.1
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.2.1 AS xx
FROM --platform=$BUILDPLATFORM golang:1.22-alpine3.20 AS base
ENV GO111MODULE=auto
ENV CGO_ENABLED=0
COPY --from=xx / /
RUN apk add --update --no-cache build-base coreutils git
WORKDIR /src
FROM base AS build
ARG TARGETPLATFORM
ARG TARGETOS
RUN --mount=type=bind,target=/src,rw \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GO_BINARY=xx-go WAIT4X_BUILD_OUTPUT=/usr/bin make build \
&& xx-verify --static /usr/bin/wait4x*
FROM scratch AS binary
COPY --from=build /usr/bin/wait4x* /
FROM base AS releaser
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
WORKDIR /work
RUN --mount=from=binary,target=/build \
--mount=type=bind,target=/src \
mkdir -p /out \
&& cp /build/wait4x* /src/README.md /src/LICENSE . \
&& tar -czvf "/out/wait4x-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz" * \
# Change dir to "/out" to prevent adding "/out" in the sha256sum command output.
&& cd /out \
&& sha256sum "wait4x-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz" > "wait4x-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz.sha256sum"
FROM scratch AS artifact
COPY --from=releaser /out /
FROM alpine:3.20
RUN apk add --update --no-cache ca-certificates tzdata
COPY --from=binary /wait4x /usr/bin/wait4x
ENTRYPOINT ["wait4x"]
CMD ["help"]