Skip to content

Commit 33088c1

Browse files
committed
hack: allow passing config file to test and shell script
One should not use their regular docker credentials here but make a special config file with only public readonly token inside. Signed-off-by: Tonis Tiigi <[email protected]>
1 parent 0d3de59 commit 33088c1

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

.github/CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ CGO_ENABLED=1 GOBUILDFLAGS="-race" ./hack/test integration
164164
Set `TEST_KEEP_CACHE=1` for the test framework to keep external dependant images in a docker volume
165165
if you are repeatedly calling `./hack/test` script. This helps to avoid rate limiting on the remote registry side.
166166

167+
You can also set `MOUNT_BUILDKIT_DOCKER_CONFIG_PATH` to forward docker config that will be used to pull
168+
test images into the container. Don't use your personal docker config, create a new one with a dedicated
169+
token that only has public read-only access.
170+
167171
If you are working behind a proxy, you can set some of or all
168172
`HTTP_PROXY=http://ip:port`, `HTTPS_PROXY=http://ip:port`, `NO_PROXY=http://ip:port` for the test framework
169173
to specify the proxy build args.

hack/shell

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,12 @@ if [ -n "$MOUNT_BUILDKIT_SOURCE" ]; then
2020
volumes="-v $(pwd):/src"
2121
fi
2222

23+
config=
24+
if [ -n "$MOUNT_BUILDKIT_DOCKER_CONFIG_PATH" ]; then
25+
if [ -f "$MOUNT_BUILDKIT_DOCKER_CONFIG_PATH" ]; then
26+
config="-v $MOUNT_BUILDKIT_DOCKER_CONFIG_PATH:/root/.docker/config.json:ro"
27+
fi
28+
fi
29+
2330
set -x
24-
docker run $SSH $volumes -it --privileged -v /tmp -e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry --rm $(cat $iidfile) ash
31+
docker run $SSH $volumes $config -it --privileged -v /tmp -e BUILDKIT_REGISTRY_MIRROR_DIR=/root/.cache/registry --rm $(cat $iidfile) ash

hack/test

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ set -eu -o pipefail
2929
: "${DOCKERFILE_RELEASES=}"
3030
: "${BUILDKIT_WORKER_RANDOM=}"
3131
: "${BUILDKIT_TEST_DISABLE_FEATURES=}"
32+
: "${MOUNT_BUILDKIT_DOCKER_CONFIG_PATH=}"
3233

3334
if [ "$TEST_DOCKERD" == "1" ]; then
3435
if [ ! -f "$TEST_DOCKERD_BINARY" ]; then
@@ -108,8 +109,11 @@ if [ "$TEST_KEEP_CACHE" != "1" ]; then
108109
fi
109110

110111
dockerConfigMount=""
111-
if [ "$GITHUB_ACTIONS" = "true" ]; then
112+
if [ "$GITHUB_ACTIONS" = "true" ] || [ -n "$MOUNT_BUILDKIT_DOCKER_CONFIG_PATH" ]; then
112113
dockerConfigPath="$HOME/.docker/config.json"
114+
if [ -n "$MOUNT_BUILDKIT_DOCKER_CONFIG_PATH" ]; then
115+
dockerConfigPath="$MOUNT_BUILDKIT_DOCKER_CONFIG_PATH"
116+
fi
113117
if [ -f "$dockerConfigPath" ]; then
114118
dockerConfigMount="-v $dockerConfigPath:/root/.docker/config.json:ro"
115119
fi

0 commit comments

Comments
 (0)