Merge branch '90-add-operatorsdk' into 'master'

Resolve "add Operator SDK-related binaries to gitlab-operator-build-base"

Closes #90

See merge request gitlab-org/gitlab-build-images!437
This commit is contained in:
Balasankar 'Balu' C 2021-11-08 03:33:51 +00:00
commit debb27c5a6

View file

@ -1,7 +1,29 @@
ARG GOLANG_VERSION=1.16 ARG GOLANG_VERSION=1.16
ARG ALPINE_VERSION=3.14
# 3.14 presents challenges: https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.14.0#faccessat2
# while building OPM. 3.13 has no issues
ARG OPM_ALPINE_VERSION=3.13
## Opm
FROM golang:${GOLANG_VERSION}-alpine${OPM_ALPINE_VERSION} as opm
ARG OPM_VERSION=1.19.1
ENV GOPROXY="https://proxy.golang.org/"
RUN apk add --no-cache make gcc musl-dev curl git bash
## on Alpine opm needs to be built from scratch due to glibc vs musl issues
RUN mkdir -p /src \
&& curl -s -L -o /src/operator-registry-${OPM_VERSION}.tgz https://github.com/operator-framework/operator-registry/archive/refs/tags/v${OPM_VERSION}.tar.gz \
&& cd /src \
&& tar -xzf operator-registry-${OPM_VERSION}.tgz \
&& ln -s operator-registry-${OPM_VERSION} operator-registry \
&& cd operator-registry \
&& make bin/opm
## Kustomize ## Kustomize
FROM golang:${GOLANG_VERSION}-alpine as kustomize FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} as kustomize
ARG KUSTOMIZE_VERSION=3.8.10 ARG KUSTOMIZE_VERSION=3.8.10
ENV GOPROXY="https://proxy.golang.org/" ENV GOPROXY="https://proxy.golang.org/"
@ -12,7 +34,7 @@ RUN mkdir /src && cd /src; \
go get sigs.k8s.io/kustomize/kustomize/v3@v${KUSTOMIZE_VERSION} go get sigs.k8s.io/kustomize/kustomize/v3@v${KUSTOMIZE_VERSION}
## Controller-gen ## Controller-gen
FROM golang:${GOLANG_VERSION}-alpine as controller-gen FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} as controller-gen
ARG CONTROLLER_GEN_VERSION=0.3.0 ARG CONTROLLER_GEN_VERSION=0.3.0
ENV GOPROXY="https://proxy.golang.org/" ENV GOPROXY="https://proxy.golang.org/"
@ -22,7 +44,7 @@ RUN mkdir /src && cd /src; \
&& go get sigs.k8s.io/controller-tools/cmd/controller-gen@v${CONTROLLER_GEN_VERSION} && go get sigs.k8s.io/controller-tools/cmd/controller-gen@v${CONTROLLER_GEN_VERSION}
## Build ## Build
FROM golang:${GOLANG_VERSION}-alpine as build FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} as build
LABEL maintainer="GitLab Distribution Team" \ LABEL maintainer="GitLab Distribution Team" \
description="Build base image for the GitLab Operator project." description="Build base image for the GitLab Operator project."
@ -30,8 +52,15 @@ LABEL maintainer="GitLab Distribution Team" \
ARG KUBEBUILDER_VERSION=2.3.1 ARG KUBEBUILDER_VERSION=2.3.1
ARG YQ_VERSION=4.7.0 ARG YQ_VERSION=4.7.0
ARG HELM_VERSION=3.5.2 ARG HELM_VERSION=3.5.2
ARG OPERATORSDK_VERSION=1.13.1
# ARG OPM_VERSION=1.19.0
RUN apk add --no-cache podman buildah curl make gcc musl-dev git bash coreutils
# make VFS podman's default storage driver to
# accomodate running podman within docker
RUN sed -i 's#^driver.*$#driver = "vfs"#g' /etc/containers/storage.conf
RUN apk add --no-cache podman curl make gcc musl-dev git bash coreutils
RUN go get -u \ RUN go get -u \
github.com/onsi/ginkgo/ginkgo \ github.com/onsi/ginkgo/ginkgo \
golang.org/x/lint/golint golang.org/x/lint/golint
@ -51,13 +80,21 @@ RUN curl --retry 6 -Ls "https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.ta
&& chmod +x /tmp/linux-amd64/helm \ && chmod +x /tmp/linux-amd64/helm \
&& mv /tmp/linux-amd64/helm /usr/local/bin/helm && mv /tmp/linux-amd64/helm /usr/local/bin/helm
# Opm
COPY --from=opm /src/operator-registry/bin/opm /usr/local/bin/opm
# Operator-SDK
RUN curl -o /usr/local/bin/operator-sdk_linux_amd64 -L \
https://github.com/operator-framework/operator-sdk/releases/download/v${OPERATORSDK_VERSION}/operator-sdk_linux_amd64 \
; chmod +x /usr/local/bin/operator-sdk_linux_amd64 ; ln -s /usr/local/bin/operator-sdk_linux_amd64 /usr/local/bin/operator-sdk
# Kustomize # Kustomize
COPY --from=kustomize /go/bin/kustomize /usr/local/bin/kustomize COPY --from=kustomize /go/bin/kustomize /usr/local/bin/kustomize
# Controller-gen # Controller-gen
COPY --from=controller-gen /go/bin/controller-gen /usr/local/bin/controller-gen COPY --from=controller-gen /go/bin/controller-gen /usr/local/bin/controller-gen
## Final image ## Final image
FROM golang:${GOLANG_VERSION}-alpine FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION}
LABEL maintainer="GitLab Distribution Team" \ LABEL maintainer="GitLab Distribution Team" \
description="Build base image for the GitLab Operator project." description="Build base image for the GitLab Operator project."
COPY --from=build / / COPY --from=build / /