This repository has been archived by the owner on Apr 28, 2022. It is now read-only.
forked from coreos/etcd-operator
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Dockerfile
54 lines (42 loc) · 1.86 KB
/
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
46
47
48
49
50
51
52
53
54
FROM golang:1.15.8 AS builder
WORKDIR /go/src/github.com/coreos/etcd-operator
ARG VERSION=dev
ARG REVISION=dev
ARG CREATED=dev
COPY vendor /go/src/
COPY cmd cmd
COPY pkg pkg
COPY version version
# Produce a static / reproducible build
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
RUN go build --ldflags "-w -s -X 'github.com/coreos/etcd-operator/version.GitSHA=$REVISION'" -o /usr/local/bin/etcd-operator github.com/coreos/etcd-operator/cmd/operator
RUN go build --ldflags "-w -s -X 'github.com/coreos/etcd-operator/version.GitSHA=$REVISION'" -o /usr/local/bin/etcd-backup-operator github.com/coreos/etcd-operator/cmd/backup-operator
RUN go build --ldflags "-w -s -X 'github.com/coreos/etcd-operator/version.GitSHA=$REVISION'" -o /usr/local/bin/etcd-restore-operator github.com/coreos/etcd-operator/cmd/restore-operator
FROM alpine AS env-builder
# Install SSL ca certificates.
# Ca-certificates is required to call HTTPS endpoints.
RUN apk update && apk add --no-cache ca-certificates && update-ca-certificates
ENV USER=etcd-operator
ENV UID=1000
RUN adduser \
--disabled-password \
--gecos "" \
--home "/srv/etcd-operator" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
# Use a distroless base image, we don't need anything else as we compiled statically
FROM scratch
# Setup environment with certificates and user
COPY --from=env-builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=env-builder /etc/passwd /etc/passwd
COPY --from=env-builder /etc/group /etc/group
COPY --from=builder /usr/local/bin/etcd-operator /usr/local/bin/etcd-operator
COPY --from=builder /usr/local/bin/etcd-backup-operator /usr/local/bin/etcd-backup-operator
COPY --from=builder /usr/local/bin/etcd-restore-operator /usr/local/bin/etcd-restore-operator
COPY --from=builder /tmp /tmp
USER etcd-operator:etcd-operator
ENTRYPOINT ["operator"]