Update mirrorred images list and add Drone config.
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This commit is contained in:
parent
ee8764fb58
commit
0d60c4b933
29
.drone.yml
Normal file
29
.drone.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: "lint"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: lint
|
||||||
|
image: koalaman/shellcheck:v0.8.0
|
||||||
|
pull: if-not-exists
|
||||||
|
commands:
|
||||||
|
- shellcheck mirror.sh
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: "mirror"
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- "lint"
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch: ["main"]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: "mirror"
|
||||||
|
image: "docker:20.10.17-dind"
|
||||||
|
pull: if-not-exists
|
||||||
|
commands:
|
||||||
|
- ./mirror.sh drone ${drone_secret}
|
@ -1 +1,2 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
echo "curlimages/curl:7.79.1"
|
echo "curlimages/curl:7.79.1"
|
||||||
|
@ -1 +1,2 @@
|
|||||||
echo "docker:19.03.13-dind docker:19.03.13 docker:20.10.8-dind"
|
#!/usr/bin/env bash
|
||||||
|
echo "docker:20.10.17-dind"
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
echo "golang:1.15.5-alpine golang:1.17.1-alpine"
|
echo "golang:1.15.5-alpine golang:1.17.1-alpine"
|
||||||
|
@ -1 +1,2 @@
|
|||||||
echo "golangci/golangci-lint:v1.32.2 golangci/golangci-lint:v1.33.0 golangci/golangci-lint:latest golangci/golangci-lint:v1.42.1"
|
#!/usr/bin/env bash
|
||||||
|
echo "golangci/golangci-lint:v1.46.2"
|
||||||
|
30
mirror.sh
30
mirror.sh
@ -3,14 +3,18 @@
|
|||||||
# The Docker Image Mirror script.
|
# The Docker Image Mirror script.
|
||||||
|
|
||||||
WHAT_TO_MIRROR=()
|
WHAT_TO_MIRROR=()
|
||||||
REGISTRY_TO_MIRROR=registry.gitlab.pztrn.name/containers/mirror
|
DESTINATION_REGISTRY=code.pztrn.name/containers/mirror
|
||||||
|
REGISTRY_USER=$1
|
||||||
|
REGISTRY_PASSWORD=$2
|
||||||
|
|
||||||
for file in $(ls ./images/*.sh); do
|
MIRROR_CONFIGS=$(ls ./images/*.sh)
|
||||||
|
for file in "${MIRROR_CONFIGS[@]}"; do
|
||||||
echo "Importing ${file}..."
|
echo "Importing ${file}..."
|
||||||
WHAT_TO_MIRROR=( ${WHAT_TO_MIRROR[@]} $(bash ${file}) )
|
# shellcheck disable=SC2086
|
||||||
|
WHAT_TO_MIRROR=( "${WHAT_TO_MIRROR[@]}" "$(bash ${file})" )
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Images to mirror: ${WHAT_TO_MIRROR[@]}"
|
echo "Images to mirror: ${WHAT_TO_MIRROR[*]}"
|
||||||
|
|
||||||
function mirror() {
|
function mirror() {
|
||||||
image=$1
|
image=$1
|
||||||
@ -18,24 +22,21 @@ function mirror() {
|
|||||||
image_version=$(echo "${image}" | cut -d":" -f 2)
|
image_version=$(echo "${image}" | cut -d":" -f 2)
|
||||||
|
|
||||||
echo -n "Mirroring ${image}... "
|
echo -n "Mirroring ${image}... "
|
||||||
docker pull "${image}" &> /dev/null
|
if ! docker pull "${image}" &> /dev/null; then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "FAIL"
|
echo "FAIL"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
image_hash=$(docker images -a | grep "^${image_name}" | grep "${image_version}" | awk {' print $3 '})
|
image_hash=$(docker images -a | grep "^${image_name}" | grep "${image_version}" | awk "{' print $3 '}")
|
||||||
echo -n "${image_hash} received... "
|
echo -n "${image_hash} received... "
|
||||||
|
|
||||||
docker tag "${image_hash}" "${REGISTRY_TO_MIRROR}/${image}" &> /dev/null
|
if ! docker tag "${image_hash}" "${DESTINATION_REGISTRY}/${image}" &> /dev/null; then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "FAIL"
|
echo "FAIL"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "pushing... "
|
echo -n "pushing... "
|
||||||
docker push "${REGISTRY_TO_MIRROR}/${image}" &> /dev/null
|
if ! docker push "${REGISTRY_TO_MIRROR}/${image}" &> /dev/null; then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "FAIL"
|
echo "FAIL"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
@ -46,7 +47,10 @@ function mirror() {
|
|||||||
docker image rm "${REGISTRY_TO_MIRROR}/${image}" &> /dev/null
|
docker image rm "${REGISTRY_TO_MIRROR}/${image}" &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Login to registry.
|
||||||
|
docker login -u "${REGISTRY_USER}" -p "${REGISTRY_PASSWORD}" "${DESTINATION_REGISTRY}"
|
||||||
|
|
||||||
# Mirror images.
|
# Mirror images.
|
||||||
for image in ${WHAT_TO_MIRROR[@]}; do
|
for image in "${WHAT_TO_MIRROR[@]}"; do
|
||||||
mirror ${image}
|
mirror "${image}"
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user