-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile-Operator
52 lines (35 loc) · 1.25 KB
/
Dockerfile-Operator
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
FROM golang:1.22-alpine AS builder
ARG GOOS
ARG GOARCH
ENV CGO_ENABLED=0
ARG COMMIT_HASH=NOT_SET
ARG OPERATOR_IMAGE=NOT_SET
ARG GIT_BRANCH=NOT_SET
ARG BUILD_TIMESTAMP=NOT_SET
ARG VERSION=NOT_SET
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN echo "${GOOS} ${GOARCH}"
RUN echo "${COMMIT_HASH} ${BUILD_TIMESTAMP} ${VERSION} ${GIT_BRANCH}"
RUN go build -ldflags="-w -s -extldflags= \
-X 'github.com/mogenius/punq/version.GitCommitHash=${COMMIT_HASH}' \
-X 'github.com/mogenius/punq/version.OperatorImage=${OPERATOR_IMAGE}' \
-X 'github.com/mogenius/punq/version.Branch=${GIT_BRANCH}' \
-X 'github.com/mogenius/punq/version.BuildTimestamp=${BUILD_TIMESTAMP}' \
-X 'github.com/mogenius/punq/version.Ver=${VERSION}'" -o bin/punq-operator .
FROM alpine:latest
ARG GOOS
ARG GOARCH
RUN apk add --no-cache curl
RUN echo "${GOOS} ${GOARCH}"
# Install kubectl
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${GOARCH}/kubectl"
RUN chmod +x kubectl
RUN mv kubectl /usr/local/bin/kubectl
WORKDIR /app
COPY --from=builder ["/app/bin/punq-operator", "."]
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
ENV GIN_MODE=release
ENTRYPOINT [ "/app/punq-operator", "operator" ]