Add base images override support

Go builder and base images override support for downstream
deployment customizations for both airshipctl and plugins.
If required, adjust the following Zuul job variables:
 - docker.base_go_image
 - docker.base_release_image
 - docker.base_plugins_build_image
 - docker.base_plugins_release_image

Closes: #515
Change-Id: Iaf4b54a353207b06c9ed6bdcae876537e73f6e44
This commit is contained in:
Roman Gorshunov
2021-04-08 13:18:42 +02:00
parent 7ed59086fc
commit 7998615a7b
5 changed files with 46 additions and 41 deletions

View File

@@ -1,8 +1,9 @@
ARG RELEASE_IMAGE=scratch
FROM ${RELEASE_IMAGE} as kctl
ARG GO_IMAGE=gcr.io/gcp-runtimes/go1-builder:1.15
ARG PLUGINS_BUILD_IMAGE=alpine:3.12.0
ARG PLUGINS_RELEASE_IMAGE=alpine:3.12.0
FROM ${PLUGINS_BUILD_IMAGE} as ctls
RUN apk update && apk add curl
# Inject custom root certificate authorities if needed
# Docker does not have a good conditional copy statement and requires that a source file exists
# to complete the copy function without error. Therefore the README.md file will be copied to
@@ -12,9 +13,11 @@ RUN update-ca-certificates
RUN curl -L "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" \
-o /kubectl
RUN chmod +x /kubectl
RUN curl -L "https://github.com/projectcalico/calicoctl/releases/download/v3.18.1/calicoctl" \
-o /calicoctl
RUN chmod +x /kubectl /calicoctl
FROM gcr.io/gcp-runtimes/go1-builder:1.15 as builder
FROM ${GO_IMAGE} as builder
ENV CGO_ENABLED=0
WORKDIR /go/src/
COPY krm-functions/toolbox/image/go.mod .
@@ -22,23 +25,7 @@ RUN /usr/local/go/bin/go mod download
COPY krm-functions/toolbox/main.go .
RUN /usr/local/go/bin/go build -v -o /usr/local/bin/config-function ./
FROM ${RELEASE_IMAGE} as calicoctl
RUN apk update && apk add curl
# Inject custom root certificate authorities if needed
# Docker does not have a good conditional copy statement and requires that a source file exists
# to complete the copy function without error. Therefore the README.md file will be copied to
# the image every time even if there are no .crt files.
COPY ./certs/* /usr/local/share/ca-certificates/
RUN update-ca-certificates
RUN curl -L "https://github.com/projectcalico/calicoctl/releases/download/v3.18.1/calicoctl" \
-o /calicoctl
RUN chmod +x /calicoctl
FROM ${RELEASE_IMAGE} as release
COPY --from=kctl /kubectl /usr/local/bin/kubectl
COPY --from=calicoctl /calicoctl /usr/local/bin/calicoctl
FROM ${PLUGINS_RELEASE_IMAGE} as release
COPY --from=ctls /kubectl /calicoctl /usr/local/bin/
COPY --from=builder /usr/local/bin/config-function /usr/local/bin/config-function
CMD ["/usr/local/bin/config-function"]