-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.buildkit
More file actions
72 lines (66 loc) · 3.13 KB
/
Copy pathDockerfile.buildkit
File metadata and controls
72 lines (66 loc) · 3.13 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Copyright the version-bump contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARG REGISTRY=docker.io
ARG ALPINE_VER=3.24.1@sha256:28bd5fe8b56d1bd048e5babf5b10710ebe0bae67db86916198a6eec434943f8b
ARG GO_VER=1.26.5-alpine@sha256:0178a641fbb4858c5f1b48e34bdaabe0350a330a1b1149aabd498d0699ff5fb2
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=""