use compressed docker images
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
IMAGE_NAME="myp-rp"
|
||||
IMAGE_TAG="latest"
|
||||
|
||||
# Specify the output file name (changed extension to .tar)
|
||||
OUTPUT_FILE="myp-rp_latest.tar"
|
||||
# Specify the output file name (changed extension to .tar.xz for compressed file)
|
||||
OUTPUT_FILE="myp-rp_latest.tar.xz"
|
||||
|
||||
# Build the 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
|
||||
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
|
||||
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
|
||||
echo "Error occurred while saving the image"
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user