use compressed docker images
This commit is contained in:
parent
81c1b98894
commit
f03cce703a
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1 +1 @@
|
|||||||
packages/reservation-platform/docker/myp-rp_latest.tar filter=lfs diff=lfs merge=lfs -text
|
packages/reservation-platform/docker/myp-rp_latest.tar.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
1
packages/reservation-platform/.gitattributes
vendored
1
packages/reservation-platform/.gitattributes
vendored
@ -1 +0,0 @@
|
|||||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
|
@ -4,8 +4,8 @@
|
|||||||
IMAGE_NAME="myp-rp"
|
IMAGE_NAME="myp-rp"
|
||||||
IMAGE_TAG="latest"
|
IMAGE_TAG="latest"
|
||||||
|
|
||||||
# Specify the output file name (changed extension to .tar)
|
# Specify the output file name (changed extension to .tar.xz for compressed file)
|
||||||
OUTPUT_FILE="myp-rp_latest.tar"
|
OUTPUT_FILE="myp-rp_latest.tar.xz"
|
||||||
|
|
||||||
# Build the Docker image from Containerfile
|
# Build the Docker image from Containerfile
|
||||||
echo "Building Docker image from Containerfile..."
|
echo "Building Docker image from Containerfile..."
|
||||||
@ -21,11 +21,35 @@ echo "Docker image built successfully"
|
|||||||
|
|
||||||
# Save the Docker image without compression
|
# Save the Docker image without compression
|
||||||
echo "Saving the Docker image..."
|
echo "Saving the Docker image..."
|
||||||
docker save ${IMAGE_NAME}:${IMAGE_TAG} > $PWD/docker/${OUTPUT_FILE}
|
docker save ${IMAGE_NAME}:${IMAGE_TAG} > $PWD/docker/myp-rp_latest.tar
|
||||||
|
|
||||||
# Check if the save operation was successful
|
# Check if the save operation was successful
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Image successfully saved to ${OUTPUT_FILE}"
|
echo "Image successfully saved to myp-rp_latest.tar"
|
||||||
|
|
||||||
|
# Compress the saved image using xz
|
||||||
|
echo "Compressing the Docker image with xz..."
|
||||||
|
xz -z $PWD/docker/myp-rp_latest.tar
|
||||||
|
|
||||||
|
# Check if the compression was successful
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
mv $PWD/docker/myp-rp_latest.tar.xz $PWD/docker/${OUTPUT_FILE}
|
||||||
|
echo "Image successfully compressed to ${OUTPUT_FILE}"
|
||||||
|
|
||||||
|
# Remove the original .tar file
|
||||||
|
echo "Cleaning up the original .tar file..."
|
||||||
|
rm $PWD/docker/myp-rp_latest.tar
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo ".tar file removed successfully"
|
||||||
|
else
|
||||||
|
echo "Error occurred while removing the .tar file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Error occurred while compressing the image"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Error occurred while saving the image"
|
echo "Error occurred while saving the image"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -4,8 +4,9 @@
|
|||||||
IMAGE_NAME="myp-rp"
|
IMAGE_NAME="myp-rp"
|
||||||
IMAGE_TAG="latest"
|
IMAGE_TAG="latest"
|
||||||
|
|
||||||
# Specify the input file name (changed extension to .tar)
|
# Specify the input file name for the compressed and uncompressed Docker image
|
||||||
INPUT_FILE="myp-rp_latest.tar"
|
INPUT_FILE="myp-rp_latest.tar"
|
||||||
|
COMPRESSED_INPUT_FILE="myp-rp_latest.tar.xz"
|
||||||
|
|
||||||
# Path to the docker directory
|
# Path to the docker directory
|
||||||
DOCKER_DIR="$PWD/docker"
|
DOCKER_DIR="$PWD/docker"
|
||||||
@ -13,7 +14,23 @@ DOCKER_DIR="$PWD/docker"
|
|||||||
# Path to the compose file
|
# Path to the compose file
|
||||||
COMPOSE_FILE="$DOCKER_DIR/compose.yml"
|
COMPOSE_FILE="$DOCKER_DIR/compose.yml"
|
||||||
|
|
||||||
# Check if the input file exists
|
# Check if the compressed input file exists
|
||||||
|
if [ -f "$DOCKER_DIR/$COMPRESSED_INPUT_FILE" ]; then
|
||||||
|
echo "Found compressed Docker image: $COMPRESSED_INPUT_FILE"
|
||||||
|
|
||||||
|
# Decompress the .tar.xz file
|
||||||
|
echo "Decompressing the Docker image..."
|
||||||
|
xz -d "$DOCKER_DIR/$COMPRESSED_INPUT_FILE"
|
||||||
|
|
||||||
|
# Check if the decompression was successful
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error occurred while decompressing $COMPRESSED_INPUT_FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Decompression completed: $INPUT_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the uncompressed input file exists
|
||||||
if [ ! -f "$DOCKER_DIR/$INPUT_FILE" ]; then
|
if [ ! -f "$DOCKER_DIR/$INPUT_FILE" ]; then
|
||||||
echo "Error: $INPUT_FILE not found in $DOCKER_DIR"
|
echo "Error: $INPUT_FILE not found in $DOCKER_DIR"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user