Skip to content

Commit

Permalink
make toolchain using current user docker config
Browse files Browse the repository at this point in the history
  • Loading branch information
namtzigla committed Dec 1, 2022
1 parent c436741 commit fddfa99
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 7 additions & 3 deletions build_defs/containers.build_defs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def container_pull(name: str, image: str, tag:str='latest', registry:str='index.
visibility = visibility,
labels = labels,
cmd = " && ".join([
f"if [[ {registry} =~ gcr\.io && ! -e /usr/local/bin/docker-credential-gcloud ]]; then echo This target requires /usr/local/bin/docker-credential-gcloud; exit 1; fi",
f"if [[ {registry} =~ gcr\.io && -z $CLOUDSDK_CONFIG ]]; then echo This target requires CLOUDSDK_CONFIG to point to where gcloud keeps its configuration; exit 1; fi",
f"if [[ {registry} =~ gcr\.io && -z $DOCKER_CONFIG ]]; then echo This target requires DOCKER_CONFIG to point to where docker keeps its configuration; exit 1; fi",
f"mkdir -p {name}",
"export USER=$(whoami)",
"export HOME=$(eval echo ~$(whoami))",
"export DOCKER_CONFIG=$HOME/.docker",
f"$TOOLS_PULLER -name {registry}/{image}:{tag} -directory {name} -os linux -architecture amd64",
f"cd {name}",
"for i in *.sha256; do mv $i ${i%.*}.tar.gz.sha256; done",
Expand Down Expand Up @@ -222,6 +222,10 @@ def container_push(name:str, srcs:list, repository:str = CONFIG.CONTAINERS.DEFAU
'fqn': [ fqn ],
},
cmd = " && ".join([
"export USER=$(whoami)",
"export HOME=$(eval echo ~$(whoami))",
"export DOCKER_CONFIG=$HOME/.docker",
f"$TOOLS_PULLER -name {registry}/{image}:{tag} -directory {name} -os linux -architecture amd64",
f"outfile={outfile}",
"prefix=plz-out/gen",
"tarfiles=\"\"",
Expand Down
7 changes: 7 additions & 0 deletions examples/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ container_pull(
tag = '20.04',
)

# pull private image from private registry
container_pull(
name = 'cibuild',
image = 'm/ci-please/build',
registry = "registry.tcncloud.net",
tag = '58'
)
# DESCRIPTION:
# This rule's srcs MUST be a multi-layer container_pull rule; it creates a container one with a single merged layer

Expand Down

0 comments on commit fddfa99

Please sign in to comment.