generated from steadybit/extension-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (52 loc) · 1.65 KB
/
Dockerfile
File metadata and controls
70 lines (52 loc) · 1.65 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
# syntax=docker/dockerfile:1
##
## Build
##
FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS build
ARG TARGETOS
ARG TARGETARCH
ARG NAME
ARG VERSION
ARG REVISION
ARG ADDITIONAL_BUILD_PARAMS
ARG SKIP_LICENSES_REPORT=false
ARG VERSION=unknown
ARG REVISION=unknown
WORKDIR /app
RUN apk add --no-cache build-base curl ca-certificates && update-ca-certificates
COPY go.mod ./
COPY go.sum ./
RUN go mod download
RUN KUBECTL_VERSION="$(curl --proto "=https" -fsSL https://dl.k8s.io/release/stable.txt)" \
&& curl --proto "=https" -fsSL -o /usr/bin/kubectl "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${TARGETARCH}/kubectl" \
&& chmod a+x /usr/bin/kubectl
COPY . .
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build \
-ldflags="\
-X 'github.com/steadybit/extension-kit/extbuild.ExtensionName=${NAME}' \
-X 'github.com/steadybit/extension-kit/extbuild.Version=${VERSION}' \
-X 'github.com/steadybit/extension-kit/extbuild.Revision=${REVISION}'" \
-o ./extension \
${ADDITIONAL_BUILD_PARAMS}
RUN make licenses-report
##
## Runtime
##
FROM alpine:3.23
ARG VERSION=unknown
ARG REVISION=unknown
LABEL "steadybit.com.discovery-disabled"="true"
LABEL "version"="${VERSION}"
LABEL "revision"="${REVISION}"
RUN echo "$VERSION" > /version.txt && echo "$REVISION" > /revision.txt
ARG USERNAME=steadybit
ARG USER_UID=10000
RUN adduser -u $USER_UID -D $USERNAME
RUN apk update && apk upgrade --no-cache && apk add curl && rm -rf /var/cache/apk/*
USER $USERNAME
WORKDIR /
COPY --from=build /app/extension /extension
COPY --from=build /usr/bin/kubectl /usr/bin/kubectl
COPY --from=build /app/licenses /licenses
EXPOSE 8089
ENTRYPOINT ["/extension"]