mattermost/server/scripts/mirror-docker-images.sh
mvitale1989 0445d8348c
CLD-5698 - Add e2e smoketests (#23590)
* Prepare: run E2E smoketests with GitHub actions (#23301)
* Port E2E testing scripts from cypress-ui-automation
* Move server to docker-compose, move E2E images to ecrpublic
* Integrate General channel renaming, fixes
* Add local automation-dashboard
 Add readme
* Add E2E smoketests
* Bump postgres to 12
* Fully rely on mattermostdevelopment images

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Saturnino Abril <saturnino.abril@gmail.com>
Co-authored-by: Antonis Stamatiou <stamatiou.antonis@gmail.com>
2023-06-12 11:56:33 +02:00

34 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
set -eu -o pipefail
# Assert that IMAGE_FILE var is given, and that the file exists
: ${IMAGES_FILE}
[ -f ${IMAGES_FILE} ] || {
echo "Error: images spec file $IMAGES_FILE does not exist. Aborting." >&2
exit 1
}
DRY_RUN=${DRY_RUN:-yes}
log () { echo "[$(date -Is)]" $*; }
get_image_specs_per_line () {
jq -c '. as $images | keys[] | . as $image | $images[.] | keys[] | {dst_img_name: $image, dst_img_tag: ., src_img: $images[$image][.]}' <$IMAGES_FILE
}
log "Pusing images from given spec file: $IMAGES_FILE"
log "Content of the spec file:"
cat $IMAGES_FILE
get_image_specs_per_line | while read IMAGE_SPEC; do
DST_IMG_NAME=$(jq -r '.dst_img_name' <<<$IMAGE_SPEC)
DST_IMG_TAG=$(jq -r '.dst_img_tag' <<<$IMAGE_SPEC)
SOURCE_IMAGE=$(jq -r '.src_img' <<<$IMAGE_SPEC)
DESTINATION_IMAGE=mattermostdevelopment/mirrored-${DST_IMG_NAME}:${DST_IMG_TAG}
if [ "${DRY_RUN,,}" = "no" ]; then
log "Pushing image: $SOURCE_IMAGE ---> $DESTINATION_IMAGE"
docker pull $SOURCE_IMAGE
docker tag $SOURCE_IMAGE $DESTINATION_IMAGE
docker push $DESTINATION_IMAGE
else
log "Pushing image: $SOURCE_IMAGE ---> $DESTINATION_IMAGE (dry run mode, set the DRY_RUN=no env var to disable)"
fi
done
log "All images pushed."