Skip to content

Commit

Permalink
Added new script that fixes windows ecr login issues (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
LikithaVemulapalli authored Sep 9, 2024
1 parent aec1d18 commit 963860f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ BIN_DIR = ${MAKEFILE_PATH}/bin
BINARY_NAME ?= ec2-metadata-mock
THIRD_PARTY_LICENSES = ${MAKEFILE_PATH}/THIRD_PARTY_LICENSES.md
GOLICENSES = ${BIN_DIR}/go-licenses
AMAZON_ECR_CREDENTIAL_HELPER_VERSION = 0.7.1

$(shell mkdir -p ${BUILD_DIR_PATH} && touch ${BUILD_DIR_PATH}/_go.mod)

Expand Down Expand Up @@ -128,7 +129,7 @@ push-docker-images-linux:

push-docker-images-windows:
${MAKEFILE_PATH}/scripts/retag-docker-images -p ${SUPPORTED_PLATFORMS_WINDOWS} -v ${VERSION} -o ${IMG} -n ${ECR_REPO}
@ECR_REGISTRY=${ECR_REGISTRY} ${MAKEFILE_PATH}/scripts/ecr-public-login
bash ${MAKEFILE_PATH}/scripts/install-amazon-ecr-credential-helper $(AMAZON_ECR_CREDENTIAL_HELPER_VERSION)
${MAKEFILE_PATH}/scripts/push-docker-images -p ${SUPPORTED_PLATFORMS_WINDOWS} -r ${ECR_REPO} -v ${VERSION} -m

push-helm-chart:
Expand Down
45 changes: 45 additions & 0 deletions scripts/install-amazon-ecr-credential-helper
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

set -euo pipefail

usage=$(cat << EOM
Download and install amazon-ecr-credential-helper for Docker client.
usage: $(basename $0) [-h] VERSION
Options:
-h Print help message then exit
Arguments:
VERSION Version number of amazon-ecr-login-helper to download and install (e.g. 0.7.1)
EOM
)

function display_help {
echo "${usage}" 1<&2
}

while getopts "h" arg; do
case "${arg}" in
h ) display_help
exit 0
;;

* ) display_help
exit 1
;;
esac
done
shift $((OPTIND-1))

version="${1:-}"
if [[ -z "${version}" ]]; then
echo "❌ no version given"
display_help
exit 1
fi

install_path="$(dirname "$(which docker-credential-wincred.exe)")"
curl -Lo "${install_path}/docker-credential-ecr-login.exe" "https://amazon-ecr-credential-helper-releases.s3.us-east-2.amazonaws.com/${version}/windows-amd64/docker-credential-ecr-login.exe"

# Update Docker to use ecr-login instead of wincred.
modified_config="$(mktemp)"
jq '.credsStore="ecr-login"' ~/.docker/config.json > "${modified_config}"
mv -f "${modified_config}" ~/.docker/config.json

0 comments on commit 963860f

Please sign in to comment.