This repository has been archived on 2024-10-30. You can view files and clone it, but cannot push or open issues or pull requests.
concourse-buildkit/entrypoint.sh

25 lines
549 B
Bash
Raw Normal View History

2022-03-09 13:40:17 +01:00
#!/usr/bin/env sh
2022-03-09 14:19:24 +01:00
DOCKER_LOGIN_FILE_TMPL='{
"auths": {
"{{REGISTRY_URL}}": {
"auth": "{{BASE64_UNAME_PW}}"
}
}
}'
2022-03-09 13:40:17 +01:00
2022-03-09 14:19:24 +01:00
docker_login() {
# TODO: detect registry url
mkdir -p "$HOME/.docker"
echo "$DOCKER_LOGIN_FILE_TMPL" | \
sed -e "s|{{BASE64_UNAME_PW}}|$(printf '%s:%s' "$username" "$password" | base64)|g" \
-e "s|{{REGISTRY_URL}}|https://index.docker.io/v1/|g" \
> "$HOME/.docker/config.json"
}
if [ -n "$username" ]; then
docker_login
fi
buildctl-daemonless.sh "$@"