airshipctl/krm-functions/applier/Dockerfile
Ruslan Aliev 4e39a436da Speed-up building applier and clusterctl images
Use caching to download go modules.

Change-Id: I9fa7d19f9daaa73675dfb8c59ffed0ad08638631
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
2021-12-16 01:50:24 +00:00

33 lines
1.3 KiB
Docker

ARG GO_IMAGE=quay.io/airshipit/golang:1.16.8-buster
ARG PLUGINS_RELEASE_IMAGE=quay.io/airshipit/alpine:3.13.5
FROM ${GO_IMAGE} as function
ARG GOPROXY=""
# 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
ENV PATH "/usr/local/go/bin:$PATH"
ENV CGO_ENABLED=0
WORKDIR /go/src/
COPY image/go.mod image/go.sum ./
RUN go mod download
COPY image/ ./
RUN go build -v -o /usr/local/bin/config-function ./
FROM ${PLUGINS_RELEASE_IMAGE} as release
# 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.
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
COPY ./certs/* /usr/local/share/ca-certificates/
RUN update-ca-certificates
COPY --from=function /usr/local/bin/config-function /usr/local/bin/config-function
ENV HOME=/home/applier
WORKDIR $HOME
RUN chmod -R a+w $HOME
CMD ["config-function"]