forked from wolfi-dev/os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdistribution.yaml
157 lines (138 loc) · 5.06 KB
/
distribution.yaml
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package:
name: distribution
version: 3.0.0
epoch: 2
description: The toolkit to pack, ship, store, and deliver container content
copyright:
- license: Apache-2.0
environment:
contents:
packages:
- busybox
- ca-certificates-bundle
- go
environment:
CGO_ENABLED: "0"
pipeline:
- uses: git-checkout
with:
expected-commit: c709432b917488208fa78a7932843d91eca59801
repository: https://github.com/distribution/distribution
tag: v${{package.version}}-beta.1
- uses: go/build
with:
ldflags: -X github.com/distribution/distribution/v3/version.Version=${{package.version}} -X github.com/distribution/distribution/v3/version.Revision=$(git rev-parse --short HEAD) -X github.com/distribution/distribution/v3/version.mainpkg=github.com/distribution/distribution/v3
output: registry
packages: ./cmd/registry
vendor: true
- uses: go/build
with:
ldflags: -X github.com/distribution/distribution/v3/version.Version=${{package.version}} -X github.com/distribution/distribution/v3/version.Revision=$(git rev-parse --short HEAD) -X github.com/distribution/distribution/v3/version.mainpkg=github.com/distribution/distribution/v3
output: digest
packages: ./cmd/digest
vendor: true
- uses: go/build
with:
ldflags: -X github.com/distribution/distribution/v3/version.Version=${{package.version}} -X github.com/distribution/distribution/v3/version.Revision=$(git rev-parse --short HEAD) -X github.com/distribution/distribution/v3/version.mainpkg=github.com/distribution/distribution/v3
output: registry-api-descriptor-template
packages: ./cmd/registry-api-descriptor-template
vendor: true
- runs: |
mkdir -p ${{targets.contextdir}}/
mkdir -p ${{targets.contextdir}}/etc/docker/registry
mkdir -p ${{targets.contextdir}}/var/lib/registry
cp ./config-example.yml ${{targets.contextdir}}/etc/docker/registry/config.yml
cp ./entrypoint.sh ${{targets.contextdir}}/entrypoint.sh
- uses: strip
subpackages:
- name: "${{package.name}}-compat"
# https://github.com/twuni/docker-registry.helm/blob/541f368966fd1d1ecbd17183acaa76e6105d8677/templates/deployment.yaml#L61-L63
description: "Compatibility package to place binaries in the location expected by upstream helm charts"
pipeline:
- runs: |
mkdir -p "${{targets.contextdir}}"/bin
ln -sf /usr/bin/registry ${{targets.contextdir}}/bin/registry
# https://github.com/distribution/distribution/discussions/4404
update:
enabled: true
manual: true
github:
identifier: distribution/distribution
strip-prefix: v
test:
environment:
contents:
packages:
- crane
pipeline:
- runs: |
#!/bin/bash
# Define image names and registry
SOURCE_IMAGE="cgr.dev/chainguard/busybox:latest"
LOCAL_REGISTRY="localhost:5000"
TARGET_IMAGE="${LOCAL_REGISTRY}/busybox:latest"
# Function to check if the previous command was successful
check_success() {
if [ $? -ne 0 ]; then
echo "Error: $1"
exit 1
fi
}
# Start the local Docker registry using the binary
echo "Starting local Docker registry..."
mkdir -p /etc/docker/registry
mkdir -p /var/lib/registry
cat <<'EOF' > /etc/docker/registry/config.yml
version: 0.1
log:
level: debug
fields:
service: registry
environment: development
storage:
delete:
enabled: true
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
tag:
concurrencylimit: 5
http:
addr: :5000
debug:
addr: :5001
prometheus:
enabled: true
path: /metrics
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3
EOF
registry serve /etc/docker/registry/config.yml &
REGISTRY_PID=$!
check_success "Failed to start local Docker registry"
# Wait for the registry to be ready
echo "Waiting for the registry to become ready..."
sleep 5
# Pull the source image
echo "Pulling image ${SOURCE_IMAGE}..."
crane pull ${SOURCE_IMAGE} ./busybox.tar
check_success "Failed to pull image ${SOURCE_IMAGE}"
# Push the image to the local registry
echo "Pushing image to ${TARGET_IMAGE}..."
crane push ./busybox.tar ${TARGET_IMAGE}
check_success "Failed to push image to ${TARGET_IMAGE}"
# Clean up the tar file
rm ./busybox.tar
# Stop the local Docker registry
echo "Stopping the local Docker registry..."
kill $REGISTRY_PID
check_success "Failed to stop local Docker registry"
echo "Test completed successfully!"
digest --version
digest --help
registry --version
registry --help