mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-09-05 08:52:23 +00:00
provide mirror support (#4148)
Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
31
test/cases/000_build/080_mirrors/config.yml
Normal file
31
test/cases/000_build/080_mirrors/config.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
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
|
||||
|
||||
proxy:
|
||||
remoteurl: https://registry-1.docker.io
|
||||
|
39
test/cases/000_build/080_mirrors/test.sh
Normal file
39
test/cases/000_build/080_mirrors/test.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that we go through the mirror when building, and fail if mirror configured but not provided
|
||||
# LABELS:
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
clean_up() {
|
||||
docker kill "${REGISTRY_NAME}" || true
|
||||
[ -n "${CACHEDIR}" ] && rm -rf "${CACHEDIR}"
|
||||
[ -n "${REGISTRY_DIR}" ] && rm -rf "${REGISTRY_DIR}"
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# container names
|
||||
REGISTRY_NAME="test-registry-$$"
|
||||
REGISTRY_DIR=$(mktemp -d)
|
||||
CACHEDIR=$(mktemp -d)
|
||||
|
||||
|
||||
|
||||
# 2 tests:
|
||||
# 1. build a package configured to use a mirror without starting mirror - should fail
|
||||
# 2. build a package configured to use a mirror after starting mirror - should succeed
|
||||
if linuxkit --mirror http://localhost:5001 --cache ${CACHEDIR} build --format kernel+initrd --name "${NAME}" ./test.yml; then
|
||||
echo "Test 1 failed: build succeeded without starting mirror"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start registry
|
||||
REGISTRY_CID=$(docker run -d --rm -v $(pwd)/config.yml:/etc/distribution/config.yml --name ${REGISTRY_NAME} -p 5001:5000 registry:3)
|
||||
|
||||
# this one should succeed
|
||||
linuxkit --mirror http://localhost:5001 --cache ${CACHEDIR} build --format kernel+initrd --name "${NAME}" ./test.yml
|
||||
|
||||
exit 0
|
10
test/cases/000_build/080_mirrors/test.yml
Normal file
10
test/cases/000_build/080_mirrors/test.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:6.6.71
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:8eea386739975a43af558eec757a7dcb3a3d2e7b
|
||||
- linuxkit/runc:667e7ea2c426a2460ca21e3da065a57dbb3369c9
|
||||
onboot:
|
||||
- name: dhcpcd
|
||||
image: linuxkit/dhcpcd:157df9ef45a035f1542ec2270e374f18efef98a5
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
@@ -11,7 +11,7 @@ set -e
|
||||
clean_up() {
|
||||
docker kill "${REGISTRY_NAME}" || true
|
||||
DOCKER_CONFIG="${DOCKER_CONFIG}" docker buildx rm "${BUILDKIT_NAME}" || true
|
||||
[ -n "${CACHDIR}" ] && rm -rf "${CACHDIR}"
|
||||
[ -n "${CACHEDIR}" ] && rm -rf "${CACHEDIR}"
|
||||
[ -n "${DOCKER_CONFIG}" ] && rm -rf "${DOCKER_CONFIG}"
|
||||
[ -n "${REGISTRY_DIR}" ] && rm -rf "${REGISTRY_DIR}"
|
||||
}
|
||||
|
Reference in New Issue
Block a user