forked from db-operator/db-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Containerfile
36 lines (26 loc) · 1 KB
/
Containerfile
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
FROM --platform=$BUILDPLATFORM registry.hub.docker.com/library/golang:1.22.2-alpine3.18 as builder
ARG OPERATOR_VERSION=1.0.0-dev
RUN apk update && apk upgrade && \
apk add --no-cache bash build-base
WORKDIR /opt/db-operator
# to reduce docker build time download dependency first before building
COPY go.mod .
COPY go.sum .
RUN go mod download
# build
COPY . .
ARG TARGETARCH
RUN GOOS=linux GOARCH=$TARGETARCH CGO_ENABLED=0 \
go build \
-ldflags="-X \"github.com/db-operator/db-operator/internal/helpers/common.OperatorVersion=$OPERATOR_VERSION\"" \
-tags build -o /usr/local/bin/db-operator cmd/main.go
FROM registry.hub.docker.com/library/alpine:3.18
LABEL org.opencontainers.image.authors="Nikolai Rodionov<allanger@badhouseplants.net>"
ENV USER_UID=1001
ENV USER_NAME=db-operator
# # install operator binary
COPY --from=builder /usr/local/bin/db-operator /usr/local/bin/db-operator
COPY ./build/bin /usr/local/bin
RUN /usr/local/bin/user_setup
ENTRYPOINT ["/usr/local/bin/entrypoint"]
USER $USER_UID