mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-11 02:52:56 +01:00
Reduce size of operator base image
- Uses the multi-stage pattern so the final stage is smaller (using the alpine variant) and copies in only what is needed from the dependencies stage. - Reduces the image size from roughly 1.19GB to roughly 654MB.
This commit is contained in:
parent
0c9578d59b
commit
1496163214
1 changed files with 12 additions and 4 deletions
|
|
@ -1,7 +1,4 @@
|
|||
FROM golang:1.14
|
||||
|
||||
LABEL maintainer="GitLab Distribution Team" \
|
||||
description="Build base image for the GitLab Operator project."
|
||||
FROM golang:1.14 AS dependencies
|
||||
|
||||
ARG KUBEBUILDER_VERSION=2.3.1
|
||||
ARG YQ_VERSION=2.4.1
|
||||
|
|
@ -16,3 +13,14 @@ RUN go get -u \
|
|||
RUN curl --retry 6 -LsO https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 \
|
||||
&& chmod +x yq_linux_amd64 \
|
||||
&& mv yq_linux_amd64 /usr/local/bin/yq
|
||||
|
||||
|
||||
FROM golang:1.14-alpine
|
||||
|
||||
LABEL maintainer="GitLab Distribution Team" \
|
||||
description="Build base image for the GitLab Operator project."
|
||||
|
||||
COPY --from=dependencies /go /go
|
||||
COPY --from=dependencies /usr/local/kubebuilder /usr/local/kubebuilder
|
||||
COPY --from=dependencies /usr/local/bin/ /usr/local/bin/
|
||||
COPY --from=dependencies /usr/local/bin/yq /usr/local/bin/yq
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue