Add BASE_IMAGE arguments to Makefile

This adds SIP_BASE_IMAGE and JUMP_HOST_BASE_IMAGE to the Makefile as
settable arguments so that a developer can set the base image when
running the make target, i.e.
SIP_BASE_IMAGE=ubuntu:18.04 make docker-build-controller

Closes: #3

Change-Id: I49a4d4f45d0f0be89ecfefcd236a0d48bb436ad7
This commit is contained in:
Ian Howell 2021-02-22 14:17:07 -06:00
parent 9fcfae7107
commit 9a949bcce1
2 changed files with 8 additions and 3 deletions

View File

@ -1,3 +1,5 @@
ARG BASE_IMAGE=gcr.io/distroless/static:nonroot
# Build the manager binary
FROM gcr.io/gcp-runtimes/go1-builder:1.13 as builder
@ -21,7 +23,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager
# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
FROM ${BASE_IMAGE}
WORKDIR /
COPY --from=builder /workspace/manager .
USER nonroot:nonroot

View File

@ -9,6 +9,9 @@ PUBLISH ?= false
JUMP_HOST_IMAGE_NAME ?= jump-host
SIP_IMAGE_NAME ?= sip
JUMP_HOST_BASE_IMAGE ?= gcr.io/google-appengine/python
SIP_BASE_IMAGE ?= gcr.io/distroless/static:nonroot
# Image URLs to build/publish images
JUMP_HOST_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/$(JUMP_HOST_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
SIP_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/$(SIP_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
@ -85,12 +88,12 @@ images: docker-build-controller docker-build-jump-host
# Build the SIP Docker image
# NOTE: DOCKER_PROXY_FLAGS can be empty.
docker-build-controller:
docker build ${DOCKER_PROXY_FLAGS} . -t ${SIP_IMG}
docker build ${DOCKER_PROXY_FLAGS} --build-arg BASE_IMAGE=${SIP_BASE_IMAGE} . -t ${SIP_IMG}
# Build the Jump Host Docker image
# NOTE: DOCKER_PROXY_FLAGS can be empty.
docker-build-jump-host:
docker build ${DOCKER_PROXY_FLAGS} -f images/jump-host/Dockerfile . -t ${JUMP_HOST_IMG}
docker build ${DOCKER_PROXY_FLAGS} -f images/jump-host/Dockerfile --build-arg BASE_IMAGE=${JUMP_HOST_BASE_IMAGE} . -t ${JUMP_HOST_IMG}
docker-push-controller:
docker push ${SIP_IMG}