Skip to content

Commit 963860f

Browse files
Added new script that fixes windows ecr login issues (#222)
1 parent aec1d18 commit 963860f

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ BIN_DIR = ${MAKEFILE_PATH}/bin
2121
BINARY_NAME ?= ec2-metadata-mock
2222
THIRD_PARTY_LICENSES = ${MAKEFILE_PATH}/THIRD_PARTY_LICENSES.md
2323
GOLICENSES = ${BIN_DIR}/go-licenses
24+
AMAZON_ECR_CREDENTIAL_HELPER_VERSION = 0.7.1
2425

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

@@ -128,7 +129,7 @@ push-docker-images-linux:
128129

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

134135
push-helm-chart:
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
usage=$(cat << EOM
6+
Download and install amazon-ecr-credential-helper for Docker client.
7+
usage: $(basename $0) [-h] VERSION
8+
Options:
9+
-h Print help message then exit
10+
Arguments:
11+
VERSION Version number of amazon-ecr-login-helper to download and install (e.g. 0.7.1)
12+
EOM
13+
)
14+
15+
function display_help {
16+
echo "${usage}" 1<&2
17+
}
18+
19+
while getopts "h" arg; do
20+
case "${arg}" in
21+
h ) display_help
22+
exit 0
23+
;;
24+
25+
* ) display_help
26+
exit 1
27+
;;
28+
esac
29+
done
30+
shift $((OPTIND-1))
31+
32+
version="${1:-}"
33+
if [[ -z "${version}" ]]; then
34+
echo "❌ no version given"
35+
display_help
36+
exit 1
37+
fi
38+
39+
install_path="$(dirname "$(which docker-credential-wincred.exe)")"
40+
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"
41+
42+
# Update Docker to use ecr-login instead of wincred.
43+
modified_config="$(mktemp)"
44+
jq '.credsStore="ecr-login"' ~/.docker/config.json > "${modified_config}"
45+
mv -f "${modified_config}" ~/.docker/config.json

0 commit comments

Comments
 (0)