forked from mattkelly/cluster-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.coordinator
54 lines (42 loc) · 1.73 KB
/
Dockerfile.coordinator
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.12.9-alpine3.10 as builder
# Add build tools
RUN apk update && \
apk add --no-cache git gcc musl-dev curl
RUN curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 && \
chmod +x /usr/local/bin/dep
ENV SRC_DIR=/go/src/github.com/containership/cluster-manager/
WORKDIR /app
# Install deps before adding rest of source so we can cache the resulting vendor dir
COPY Gopkg.toml Gopkg.lock $SRC_DIR
RUN cd $SRC_DIR && \
dep ensure -vendor-only
# Install kubectl
ARG K8S_VERSION=v1.12.0
RUN set -x && \
apk --update upgrade && \
apk add --update ca-certificates openssl && update-ca-certificates && \
rm -rf /var/cache/apk/* && \
wget -O /kubectl https://storage.googleapis.com/kubernetes-release/release/$K8S_VERSION/bin/linux/amd64/kubectl && \
chmod +x /kubectl
# Add the source code:
COPY . $SRC_DIR
# Build it:
ARG GIT_DESCRIBE
ARG GIT_COMMIT
RUN cd $SRC_DIR && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags \
"-X github.com/containership/cluster-manager/pkg/buildinfo.gitDescribe=${GIT_DESCRIBE} \
-X github.com/containership/cluster-manager/pkg/buildinfo.gitCommit=${GIT_COMMIT} \
-X github.com/containership/cluster-manager/pkg/buildinfo.unixTime=`date '+%s'` \
-w" \
-a -tags netgo \
-o coordinator cmd/cloud_coordinator/coordinator.go && \
cp coordinator /app/
# Create Docker image of just the binary
FROM scratch as runner
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /app/coordinator .
COPY --from=builder /kubectl /etc/kubectl/kubectl
ENV KUBECTL_PATH=/etc/kubectl/kubectl
CMD ["./coordinator"]