gitlab-build-images/Dockerfile.gitlab-operator-build-base
Mitchell Nielsen 1496163214 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.
2021-01-28 12:37:23 -05:00

26 lines
967 B
Docker

FROM golang:1.14 AS dependencies
ARG KUBEBUILDER_VERSION=2.3.1
ARG YQ_VERSION=2.4.1
RUN go get -u \
github.com/onsi/ginkgo/ginkgo \
golang.org/x/lint/golint \
&& curl -L https://go.kubebuilder.io/dl/${KUBEBUILDER_VERSION}/linux/amd64 | tar -xz -C /tmp/ \
&& mv /tmp/kubebuilder_${KUBEBUILDER_VERSION}_linux_amd64 /usr/local/kubebuilder \
&& ln -sfv /usr/local/kubebuilder/bin/* /usr/local/bin
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