Skip to content

Commit ab15f92

Browse files
authoredOct 15, 2024
Make controller base_image version an argument (#551)
Description of changes: This change allows us to pass the base image version as an argument allowing us to pass the latest one after each release By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 846d41f commit ab15f92

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed
 

‎Dockerfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Base image to use at runtime
2-
ARG base_image=public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2024-04-01-1711929684.2
2+
ARG base_image=public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot
33

44
# Golang image to use for compiling the manager
55
ARG builder_image=public.ecr.aws/docker/library/golang
66

77
# Version of Golang
88
ARG golang_version
9+
# Version of eks-distro
10+
ARG eks_distro_version
911

1012
# Build the manager binary
1113
FROM $builder_image:$golang_version as builder
@@ -49,7 +51,7 @@ RUN GIT_VERSION=$service_controller_git_version && \
4951
-X ${VERSION_PKG}.BuildDate=${BUILD_DATE}" \
5052
-a -o $work_dir/bin/controller $work_dir/cmd/controller/main.go
5153

52-
FROM $base_image
54+
FROM $base_image:$eks_distro_version
5355
ARG base_image
5456
LABEL org.opencontainers.image.base.name=$base_image
5557
ARG service_alias

‎Dockerfile.local

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Base image to use at runtime
2-
ARG base_image=public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2023-09-06-1694026927.2
2+
ARG base_image=public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot
33

44
# Golang image to use for compiling the manager
55
ARG builder_image=public.ecr.aws/docker/library/golang
66

77
# Version of Golang
88
ARG golang_version
99

10+
# Version of eks-distro
11+
ARG eks_distro_version
12+
1013
# Build the manager binary
1114
FROM $builder_image:$golang_version as builder
1215

@@ -68,7 +71,7 @@ RUN GIT_VERSION=$service_controller_git_version && \
6871
-X ${VERSION_PKG}.BuildDate=${BUILD_DATE}" \
6972
-a -o $work_dir/bin/controller $work_dir/cmd/controller/main.go
7073

71-
FROM $base_image
74+
FROM $base_image:$eks_distro_version
7275
ARG base_image
7376
LABEL org.opencontainers.image.base.name=$base_image
7477
ARG service_alias

‎scripts/build-controller-image.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -eo pipefail
55
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
66
SCRIPTS_DIR=$DIR
77
ROOT_DIR=$DIR/..
8+
TEST_INFRA_DIR=$ROOT_DIR/../test-infra
89
DOCKERFILE_PATH=$ROOT_DIR/Dockerfile
910
ACK_DIR=$ROOT_DIR/..
1011
DOCKERFILE=${DOCKERFILE:-"$DOCKERFILE_PATH"}
@@ -88,9 +89,10 @@ if ! is_public_ecr_logged_in; then
8889
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
8990
fi
9091

91-
pushd "$ROOT_DIR" 1>/dev/null
92-
# Get the golang version from the code-generator
93-
GOLANG_VERSION=${GOLANG_VERSION:-"$(go list -f {{.GoVersion}} -m)"}
92+
pushd "$TEST_INFRA_DIR" 1>/dev/null
93+
# Get the golang version from build_config.yaml
94+
GOLANG_VERSION=$(cat build_config.yaml | yq .go_version)
95+
BASE_IMAGE_VERSION=$(cat build_config.yaml | yq .eks_distro_version)
9496
popd 1>/dev/null
9597

9698
# if local build
@@ -109,6 +111,7 @@ if ! docker build \
109111
--build-arg service_controller_git_commit="$SERVICE_CONTROLLER_GIT_COMMIT" \
110112
--build-arg build_date="$BUILD_DATE" \
111113
--build-arg golang_version="${GOLANG_VERSION}" \
114+
--build-arg eks_distro_version="${BASE_IMAGE_VERSION}" \
112115
--build-arg go_arch="$GOARCH" \
113116
--progress plain \
114117
"${DOCKER_BUILD_CONTEXT}"; then

0 commit comments

Comments
 (0)