-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
45 lines (32 loc) · 977 Bytes
/
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
# syntax=docker/dockerfile:1
ARG GO_VERSION=1.21
FROM --platform=$TARGETPLATFORM golang:${GO_VERSION} AS build
ARG TARGETPLATFORM
ARG project_name=generator
ARG build_in_docker=false
WORKDIR /src
COPY . /src
RUN mkdir -p dist/$TARGETPLATFORM
RUN --mount=type=cache,target=/go/pkg/mod/ \
if [ "$build_in_docker" = "true" ]; then \
go mod download -x; \
fi
RUN --mount=type=cache,target=/go/pkg/mod/ \
if [ "$build_in_docker" = "true" ]; then \
CGO_ENABLED=0 go build -ldflags="-s -w" -v -o dist/$TARGETPLATFORM/$project_name; \
fi
FROM --platform=$TARGETPLATFORM bitnami/kubectl:latest AS final
ARG TARGETPLATFORM
ARG project_name=generator
ARG build_in_docker=false
WORKDIR /src
COPY --from=build src/keygen.sh .
COPY --from=build src/dist/$TARGETPLATFORM/$project_name ./generator
ARG version
ARG tag
ENV VERSION=${version:-develop}
ENV TAG=${tag:-main}
USER root
RUN chmod +x /src/keygen.sh
USER 1001
ENTRYPOINT [ "./keygen.sh" ]