chore: add hack/gen-containerd-hosts.sh (#1361)

Signed-off-by: Jim Ma <majinjing3@gmail.com>
This commit is contained in:
Jim Ma 2022-06-02 18:00:36 +08:00 committed by Gaius
parent e4eaa6195c
commit c8ea36186f
No known key found for this signature in database
GPG Key ID: 8B4E5D1290FA2FFB
1 changed files with 29 additions and 0 deletions

29
hack/gen-containerd-hosts.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
# the register to pull image, like "docker.io", when pull image with "docker.io/library/alpine:latest"
registry=${1:-${REGISTRY}}
# the real server which serves image pulling, like "registry-1.docker.io"
# in normal case, registry_server is same with registry
registry_server=${REGISTRY_SERVER:-${registry}}
# dragonfly proxy url
d7y_proxy=${2:-http://127.0.0.1:65001}
if [[ -z "${registry}" ]]; then
echo empty registry domain
exit 1
fi
conf_dir=${CONTAINED_CONFIG_DIR:-/etc/containerd/certs.d}
mkdir -p "$conf_dir/${registry}"
cat << EOF > "$conf_dir/${registry}"/hosts.toml
server = "https://${registry_server}"
[host."${d7y_proxy}"]
capabilities = ["pull", "resolve"]
[host."${d7y_proxy}".header]
X-Dragonfly-Registry = ["https://${registry_server}"]
EOF