forked from gardener/gardener
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.local
198 lines (141 loc) · 6.04 KB
/
Dockerfile.local
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
############# base
FROM alpine:3.13.7 AS base
# Define GOTRACEBACK to mark this container as using the Go language runtime
# for `skaffold debug` (https://skaffold.dev/docs/workflows/debug/).
ENV GOTRACEBACK=single
RUN apk add --update tzdata
############# builder-base #############
FROM golang:1.17.9 AS builder-base
WORKDIR /go/src/github.com/gardener/gardener
# `skaffold debug` sets SKAFFOLD_GO_GCFLAGS to disable compiler optimizations
ARG SKAFFOLD_GO_GCFLAGS
ARG TARGETOS
ARG TARGETARCH
ENV CGO_ENABLED=0
ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH
ARG VERSION
COPY VERSION .
RUN echo "-X k8s.io/component-base/version.gitVersion=${VERSION:-$(cat VERSION)} \
-X k8s.io/component-base/version.buildDate=$(date '+%Y-%m-%dT%H:%M:%S%z' | sed 's/\([0-9][0-9]\)$/:\1/g') \
-X k8s.io/component-base/version/verflag.programName=Gardener" > /tmp/build-flags
############# apiserver #############
FROM builder-base AS builder-apiserver
# manually copy the packages we need to keep the build context slim
COPY cmd cmd
COPY pkg pkg
COPY plugin plugin
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" \
-ldflags="$(cat /tmp/build-flags)" \
-o /gardener-apiserver ./cmd/gardener-apiserver
FROM base AS apiserver
COPY --from=builder-apiserver /gardener-apiserver /gardener-apiserver
ENTRYPOINT ["/gardener-apiserver"]
############# controller-manager #############
FROM builder-base AS builder-controller-manager
# manually copy the packages we need to keep the build context slim
COPY cmd cmd
COPY pkg pkg
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" \
-ldflags="$(cat /tmp/build-flags)" \
-o /gardener-controller-manager ./cmd/gardener-controller-manager
FROM base AS controller-manager
COPY --from=builder-controller-manager /gardener-controller-manager /gardener-controller-manager
ENTRYPOINT ["/gardener-controller-manager"]
############# scheduler #############
FROM builder-base AS builder-scheduler
# manually copy the packages we need to keep the build context slim
COPY cmd cmd
COPY pkg pkg
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" \
-ldflags="$(cat /tmp/build-flags)" \
-o /gardener-scheduler ./cmd/gardener-scheduler
FROM base AS scheduler
COPY --from=builder-scheduler /gardener-scheduler /gardener-scheduler
ENTRYPOINT ["/gardener-scheduler"]
############# admission-controller #############
FROM builder-base AS builder-admission-controller
# manually copy the packages we need to keep the build context slim
COPY cmd cmd
COPY pkg pkg
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" \
-ldflags="$(cat /tmp/build-flags)" \
-o /gardener-admission-controller ./cmd/gardener-admission-controller
FROM base AS admission-controller
COPY --from=builder-admission-controller /gardener-admission-controller /gardener-admission-controller
ENTRYPOINT ["/gardener-admission-controller"]
############# resource-manager #############
FROM builder-base AS builder-resource-manager
# manually copy the packages we need to keep the build context slim
COPY cmd cmd
COPY pkg pkg
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" \
-ldflags="$(cat /tmp/build-flags)" \
-o /gardener-resource-manager ./cmd/gardener-resource-manager
FROM base AS resource-manager
COPY --from=builder-resource-manager /gardener-resource-manager /gardener-resource-manager
ENTRYPOINT ["/gardener-resource-manager"]
############# seed-admission-controller #############
FROM builder-base AS builder-seed-admission-controller
# manually copy the packages we need to keep the build context slim
COPY cmd cmd
COPY pkg pkg
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" \
-ldflags="$(cat /tmp/build-flags)" \
-o /gardener-seed-admission-controller ./cmd/gardener-seed-admission-controller
FROM base AS seed-admission-controller
COPY --from=builder-seed-admission-controller /gardener-seed-admission-controller /gardener-seed-admission-controller
ENTRYPOINT ["/gardener-seed-admission-controller"]
############# gardenlet #############
FROM builder-base AS builder-gardenlet
# manually copy the packages we need to keep the build context slim
COPY charts/images.yaml charts/charts.go charts/
COPY cmd cmd
COPY pkg pkg
COPY third_party third_party
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" \
-ldflags="$(cat /tmp/build-flags)" \
-o /gardenlet ./cmd/gardenlet
FROM base AS gardenlet
RUN apk add --update openvpn
COPY charts /charts
COPY --from=builder-gardenlet /gardenlet /gardenlet
ENTRYPOINT ["/gardenlet"]
############# extension-provider-local #############
FROM builder-base AS builder-extension-provider-local
# manually copy the packages we need to keep the build context slim
COPY charts/charts.go charts/
COPY cmd cmd
COPY extensions extensions
COPY pkg pkg
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" \
-ldflags="$(cat /tmp/build-flags)" \
-o /gardener-extension-provider-local ./cmd/gardener-extension-provider-local
FROM base AS extension-provider-local
COPY charts/gardener/provider-local/internal /charts/gardener/provider-local/internal
COPY --from=builder-extension-provider-local /gardener-extension-provider-local /gardener-extension-provider-local
ENTRYPOINT ["/gardener-extension-provider-local"]