Avoid cred helpers errors in release script

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2018-09-26 13:44:42 -07:00
parent 54c3136e34
commit 772a307192
3 changed files with 26 additions and 2 deletions

View File

@ -20,6 +20,12 @@ following repositories:
- docker/compose
- docker/compose-tests
### A local Python environment
While most of the release script is running inside a Docker container,
fetching local Docker credentials depends on the `docker` Python package
being available locally.
### A Github account and Github API token
Your Github account needs to have write access on the `docker/compose` repo.

View File

@ -15,9 +15,19 @@ if test -z $BINTRAY_TOKEN; then
exit 1
fi
docker run -e GITHUB_TOKEN=$GITHUB_TOKEN -e BINTRAY_TOKEN=$BINTRAY_TOKEN -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK -it \
if test -z $(python -c "import docker; print(docker.version)" 2>/dev/null); then
echo "This script requires the 'docker' Python package to be installed locally"
exit 1
fi
hub_credentials=$(python -c "from docker import auth; cfg = auth.load_config(); print(auth.encode_header(auth.resolve_authconfig(cfg, 'docker.io')).decode('ascii'))")
docker run -it \
-e GITHUB_TOKEN=$GITHUB_TOKEN \
-e BINTRAY_TOKEN=$BINTRAY_TOKEN \
-e SSH_AUTH_SOCK=$SSH_AUTH_SOCK \
-e HUB_CREDENTIALS=$hub_credentials \
--mount type=bind,source=$(pwd),target=/src \
--mount type=bind,source=$HOME/.docker,target=/root/.docker \
--mount type=bind,source=$HOME/.gitconfig,target=/root/.gitconfig \
--mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
--mount type=bind,source=$HOME/.ssh,target=/root/.ssh \

View File

@ -2,6 +2,8 @@ from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
import base64
import json
import os
import shutil
@ -15,6 +17,12 @@ class ImageManager(object):
def __init__(self, version):
self.docker_client = docker.APIClient(**docker.utils.kwargs_from_env())
self.version = version
if 'HUB_CREDENTIALS' in os.environ:
print('HUB_CREDENTIALS found in environment, issuing login')
credentials = json.loads(base64.urlsafe_b64decode(os.environ['HUB_CREDENTIALS']))
self.docker_client.login(
username=credentials['Username'], password=credentials['Password']
)
def build_images(self, repository, files):
print("Building release images...")