Add docker login.

This commit is contained in:
redxef 2022-03-09 14:19:24 +01:00
parent 1daab2b5fc
commit 248cb76ac6
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921
2 changed files with 22 additions and 2 deletions

View file

@ -1,5 +1,6 @@
FROM moby/buildkit
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT [ "entrypoint.sh" ]

View file

@ -1,5 +1,24 @@
#!/usr/bin/env sh
buildctl-deamonless.sh
DOCKER_LOGIN_FILE_TMPL='{
"auths": {
"{{REGISTRY_URL}}": {
"auth": "{{BASE64_UNAME_PW}}"
}
}
}'
"$@"
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 "$@"