Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ VERSION = $(shell git describe --tags --always --dirty)
LATEST_RELEASE_TAG=$(shell git describe --tags --abbrev=0)
PREVIOUS_RELEASE_TAG=$(shell git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`)
REPO_FULL_NAME=aws/aws-node-termination-handler
ECR_REGISTRY ?= public.ecr.aws/r6b0f9a1
ECR_REPO ?= ${ECR_REGISTRY}/aws-node-termination-handler
IMG ?= amazon/aws-node-termination-handler
IMG_TAG ?= ${VERSION}
IMG_W_TAG = ${IMG}:${IMG_TAG}
Expand Down Expand Up @@ -47,10 +49,16 @@ build-docker-images-windows:
push-docker-images:
@docker login -u ${DOCKER_USERNAME} -p="${DOCKERHUB_TOKEN}"
${MAKEFILE_PATH}/scripts/push-docker-images -p ${SUPPORTED_PLATFORMS_LINUX} -r ${IMG} -v ${VERSION} -m
${MAKEFILE_PATH}/scripts/retag-docker-images -p ${SUPPORTED_PLATFORMS_LINUX} -v ${VERSION} -o ${IMG} -n ${ECR_REPO}
@ECR_REGISTRY=${ECR_REGISTRY} ${MAKEFILE_PATH}/scripts/ecr-public-login
${MAKEFILE_PATH}/scripts/push-docker-images -p ${SUPPORTED_PLATFORMS_LINUX} -r ${ECR_REPO} -v ${VERSION} -m

push-docker-images-windows:
@docker login -u ${DOCKER_USERNAME} -p="${DOCKERHUB_TOKEN}"
${MAKEFILE_PATH}/scripts/push-docker-images -p ${SUPPORTED_PLATFORMS_WINDOWS} -r ${IMG} -v ${VERSION} -m
${MAKEFILE_PATH}/scripts/retag-docker-images -p ${SUPPORTED_PLATFORMS_LINUX} -v ${VERSION} -o ${IMG} -n ${ECR_REPO}
@ECR_REGISTRY=${ECR_REGISTRY} ${MAKEFILE_PATH}/scripts/ecr-public-login
${MAKEFILE_PATH}/scripts/push-docker-images -p ${SUPPORTED_PLATFORMS_WINDOWS} -r ${ECR_REPO} -v ${VERSION} -m

version:
@echo ${VERSION}
Expand Down
2 changes: 1 addition & 1 deletion config/helm/aws-node-termination-handler/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Declare variables to be passed into your templates.

image:
repository: amazon/aws-node-termination-handler
repository: public.ecr.aws/r6b0f9a1/aws-node-termination-handler
tag: v1.11.1
pullPolicy: IfNotPresent
pullSecrets: []
Expand Down
9 changes: 9 additions & 0 deletions scripts/ecr-public-login
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail

if [[ -z "${ECR_REGISTRY}" ]]; then
echo "The env var ECR_REGISTRY must be set"
exit 1
fi

docker login --username AWS -p="$(docker run --rm --env-file <(env | grep AWS) -i amazon/aws-cli ecr-public get-login-password --region us-east-1)" ${ECR_REGISTRY}
55 changes: 55 additions & 0 deletions scripts/retag-docker-images
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
set -euo pipefail

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

REPO_ROOT_PATH=$SCRIPTPATH/../
MAKE_FILE_PATH=$REPO_ROOT_PATH/Makefile

VERSION=$(make -s -f $MAKE_FILE_PATH version)
PLATFORMS=("linux/amd64")


USAGE=$(cat << 'EOM'
Usage: retag-docker-images [-p <platform pairs>]
Tags created docker images with a new prefix

Example: retag-docker-images -p "linux/amd64,linux/arm" -o <OLD_REPO_PREFIX> -n <NEW_REPO_PREFIX>
Optional:
-p Platform pair list (os/architecture) [DEFAULT: linux/amd64]
-o OLD IMAGE REPO to retag
-n NEW IMAGE REPO to tag with
-v VERSION: The application version of the docker image [DEFAULT: output of `make version`]
EOM
)

# Process our input arguments
while getopts "p:o:n:v:" opt; do
case ${opt} in
p ) # Platform Pairs
IFS=',' read -ra PLATFORMS <<< "$OPTARG"
;;
o ) # Old Image Repo
OLD_IMAGE_REPO="$OPTARG"
;;
n ) # New Image Repo
NEW_IMAGE_REPO="$OPTARG"
;;
v ) # Image Version
VERSION="$OPTARG"
;;
\? )
echo "$USAGE" 1>&2
exit
;;
esac
done

for os_arch in "${PLATFORMS[@]}"; do
os=$(echo $os_arch | cut -d'/' -f1)
arch=$(echo $os_arch | cut -d'/' -f2)

old_img_tag="$OLD_IMAGE_REPO:$VERSION-$os-$arch"
new_img_tag="$NEW_IMAGE_REPO:$VERSION-$os-$arch"
docker tag ${old_img_tag} ${new_img_tag}
done