forked from atkrad/wait4x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
47 lines (36 loc) · 1.31 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
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.1.0 AS xx
FROM --platform=$BUILDPLATFORM golang:1.18.1-alpine3.15 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
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 -z "wait4x-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz" > "wait4x-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz.sha256sum"
FROM scratch AS artifact
COPY --from=releaser /out /
FROM alpine:3.15
RUN apk add --no-cache ca-certificates
COPY --from=binary /wait4x /usr/bin/wait4x
ENTRYPOINT ["wait4x"]
CMD ["help"]