-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathtest-registry.sh
executable file
·48 lines (36 loc) · 1.62 KB
/
test-registry.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
## This script will test creating a manifest list against a specified registry
## that claims to support the OCI distribution API and the Docker v2.2 image
## specification or OCI v1 image spec.
## It expects `manifest-tool` to be in the $PATH as well as the docker client.
## You must be authenticated via `docker login` to the registry provided or
## whatever method that registry provides for inserting docker authentication.
## It will pull 4 images from DockerHub (alpine for 4 architectures)
## and tag them against the provided registry; push them as images to that
## registry/repo and then use the `manifest-tool` to assemble them into a
## manifest list and push using the V2 API and V2 features (like cross-repository
## push and references to blobs already existing)
_REGISTRY="${1}"
_IMAGELIST="s390x/alpine
ppc64le/alpine
aarch64/alpine
amd64/alpine"
[ -z "${_REGISTRY}" ] && {
echo "Please provide a registry URL + namespace/repo name as the first parameter"
exit 1
}
echo "Warning: some commands will fail if you are not authenticated to ${_REGISTRY}"
echo ">> 1: Pulling required images from DockerHub"
for i in $_IMAGELIST; do
docker pull ${i}:latest
done
echo ">> 2: Tagging and pushing images to registry ${_REGISTRY}"
for i in $_IMAGELIST; do
target="${i/\//_}"
echo docker tag ${i}:latest ${_REGISTRY}/${target}:latest
docker tag ${i}:latest ${_REGISTRY}/${target}:latest
docker push ${_REGISTRY}/${target}:latest
done
echo ">> 3: Creating manifest list on registry ${_REGISTRY}"
sed s,__REGISTRY__,${_REGISTRY}, test-registry.yml >test-registry.yaml
manifest-tool --debug push from-spec test-registry.yaml