2020-12-21 01:31:10 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DOCKER_IMAGE=$1
|
|
|
|
TARGET_PATH=$2
|
|
|
|
|
|
|
|
[ -z "$TARGET_PATH" ] && TARGET_PATH=./target
|
|
|
|
|
2022-12-21 00:07:58 -06:00
|
|
|
DOCKER_IMAGE_NAME=$(echo $DOCKER_IMAGE | cut -d: -f1 | sed "s/-$DOCKER_USERNAME\$//")
|
2020-12-21 01:31:10 -06:00
|
|
|
DOCKER_CONTAINER=$DOCKER_IMAGE_NAME
|
|
|
|
TARGET_VERSIONS_PATH=$TARGET_PATH/versions/dockers/$DOCKER_IMAGE_NAME
|
|
|
|
|
|
|
|
[ -d $TARGET_VERSIONS_PATH ] && rm -rf $TARGET_VERSIONS_PATH
|
|
|
|
mkdir -p $TARGET_VERSIONS_PATH
|
|
|
|
|
|
|
|
export DOCKER_CLI_EXPERIMENTAL=enabled
|
|
|
|
|
|
|
|
# Remove the old docker container if existing
|
|
|
|
if docker container inspect $DOCKER_IMAGE > /dev/null 2>&1; then
|
|
|
|
docker container rm $DOCKER_IMAGE > /dev/null
|
|
|
|
fi
|
|
|
|
docker create --name $DOCKER_CONTAINER --entrypoint /bin/bash $DOCKER_IMAGE
|
|
|
|
docker cp -L $DOCKER_CONTAINER:/etc/os-release $TARGET_VERSIONS_PATH/
|
|
|
|
docker cp -L $DOCKER_CONTAINER:/usr/local/share/buildinfo/pre-versions $TARGET_VERSIONS_PATH/
|
|
|
|
docker cp -L $DOCKER_CONTAINER:/usr/local/share/buildinfo/post-versions $TARGET_VERSIONS_PATH/
|
|
|
|
docker container rm $DOCKER_CONTAINER
|