-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.buildkit
58 lines (53 loc) · 2.55 KB
/
Dockerfile.buildkit
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
50
51
52
53
54
55
56
57
ARG REGISTRY=docker.io
ARG ALPINE_VER=3.20.3@sha256:1e42bbe2508154c9126d48c2b8a75420c3544343bf86fd041fb7527e017a4b4a
ARG GO_VER=1.23.3-alpine@sha256:c694a4d291a13a9f9d94933395673494fc2cc9d4777b85df3a7e70b3492d3574
FROM --platform=$BUILDPLATFORM ${REGISTRY}/library/golang:${GO_VER} AS build
RUN apk add --no-cache \
ca-certificates \
make
RUN adduser -D appuser
WORKDIR /src
COPY . /src/
RUN --mount=type=cache,id=gomod,target=/go/pkg/mod/cache \
--mount=type=cache,id=goroot,target=/root/.cache/go-build \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
make bin/version-bump
USER appuser
CMD [ "bin/version-bump" ]
FROM scratch AS artifact
COPY --from=build /src/bin/version-bump /version-bump
FROM ${REGISTRY}/library/alpine:${ALPINE_VER} AS release-alpine
COPY --from=build /etc/passwd /etc/group /etc/
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build --chown=appuser /home/appuser /home/appuser
COPY --from=build /src/bin/version-bump /usr/local/bin/version-bump
USER appuser
CMD [ "version-bump", "--help" ]
LABEL maintainer="" \
org.opencontainers.image.authors="https://github.com/sudo-bmitch" \
org.opencontainers.image.url="https://github.com/sudo-bmitch/version-bump" \
org.opencontainers.image.documentation="https://github.com/sudo-bmitch/version-bump" \
org.opencontainers.image.source="https://github.com/sudo-bmitch/version-bump" \
org.opencontainers.image.version="latest" \
org.opencontainers.image.vendor="" \
org.opencontainers.image.licenses="Apache 2.0" \
org.opencontainers.image.title="version-bump" \
org.opencontainers.image.description=""
FROM scratch AS release-scratch
COPY --from=build /etc/passwd /etc/group /etc/
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build --chown=appuser /home/appuser /home/appuser
COPY --from=build /src/bin/version-bump /version-bump
USER appuser
ENTRYPOINT [ "/version-bump" ]
CMD [ "--help" ]
LABEL maintainer="" \
org.opencontainers.image.authors="https://github.com/sudo-bmitch" \
org.opencontainers.image.url="https://github.com/sudo-bmitch/version-bump" \
org.opencontainers.image.documentation="https://github.com/sudo-bmitch/version-bump" \
org.opencontainers.image.source="https://github.com/sudo-bmitch/version-bump" \
org.opencontainers.image.version="latest" \
org.opencontainers.image.vendor="" \
org.opencontainers.image.licenses="Apache 2.0" \
org.opencontainers.image.title="version-bump" \
org.opencontainers.image.description=""