diff --git a/packages/reservation-platform/docker/build_image.sh b/packages/reservation-platform/docker/build_image.sh index 24368ec..fe771cb 100755 --- a/packages/reservation-platform/docker/build_image.sh +++ b/packages/reservation-platform/docker/build_image.sh @@ -1,50 +1,79 @@ #!/bin/bash -# Specify the image name and tag -IMAGE_NAME="myp-rp" -IMAGE_TAG="latest" +# Specify the image names and tags +MYP_RP_IMAGE_NAME="myp-rp" +MYP_RP_IMAGE_TAG="latest" +CADDY_IMAGE_NAME="caddy" +CADDY_IMAGE_TAG="latest" # Create a new builder instance with a sensible name BUILDER_NAME="myp-rp-arm64-builder" echo "Creating a new builder instance named $BUILDER_NAME..." docker buildx create --name $BUILDER_NAME --use -# Build the Docker image from Dockerfile for arm64 -echo "Building Docker image from Dockerfile for arm64..." -docker buildx build --platform linux/arm64 -t ${IMAGE_NAME}:${IMAGE_TAG} -f $PWD/Dockerfile $PWD --output type=docker,dest=docker/${IMAGE_NAME}_${IMAGE_TAG}.tar +# Build the myp-rp Docker image from Dockerfile for arm64 +echo "Building myp-rp Docker image from Dockerfile for arm64..." +docker buildx build --platform linux/arm64 -t ${MYP_RP_IMAGE_NAME}:${MYP_RP_IMAGE_TAG} -f $PWD/Dockerfile $PWD --output type=docker,dest=docker/${MYP_RP_IMAGE_NAME}_${MYP_RP_IMAGE_TAG}.tar # Check if the build was successful if [ $? -ne 0 ]; then - echo "Error occurred while building the Docker image" + echo "Error occurred while building the myp-rp Docker image" docker buildx rm $BUILDER_NAME exit 1 fi -echo "Docker image built successfully" +echo "myp-rp Docker image built successfully" -# Compress the tar file using xz -COMPRESSED_FILE="docker/${IMAGE_NAME}_${IMAGE_TAG}.tar.xz" -echo "Compressing the image to $COMPRESSED_FILE..." +# Compress the myp-rp tar file using xz +MYP_RP_COMPRESSED_FILE="docker/${MYP_RP_IMAGE_NAME}_${MYP_RP_IMAGE_TAG}.tar.xz" +echo "Compressing the myp-rp image to $MYP_RP_COMPRESSED_FILE..." # Check if the compressed file exists and remove it -if [ -f "$COMPRESSED_FILE" ]; then - echo "Removing existing compressed file $COMPRESSED_FILE..." - rm "$COMPRESSED_FILE" +if [ -f "$MYP_RP_COMPRESSED_FILE" ]; then + echo "Removing existing compressed file $MYP_RP_COMPRESSED_FILE..." + rm "$MYP_RP_COMPRESSED_FILE" fi -# Proceed with compression -xz -z docker/${IMAGE_NAME}_${IMAGE_TAG}.tar +# Proceed with compression for myp-rp +xz -z docker/${MYP_RP_IMAGE_NAME}_${MYP_RP_IMAGE_TAG}.tar # Check if the compression was successful if [ $? -ne 0 ]; then - echo "Error occurred while compressing the Docker image" + echo "Error occurred while compressing the myp-rp Docker image" docker buildx rm $BUILDER_NAME exit 1 fi -echo "Docker image compressed successfully as docker/${IMAGE_NAME}_${IMAGE_TAG}.tar.xz" +echo "myp-rp Docker image compressed successfully as $MYP_RP_COMPRESSED_FILE" + +# Save the caddy Docker image +echo "Saving caddy Docker image..." +docker pull ${CADDY_IMAGE_NAME}:${CADDY_IMAGE_TAG} +docker save ${CADDY_IMAGE_NAME}:${CADDY_IMAGE_TAG} > docker/${CADDY_IMAGE_NAME}.tar + +# Compress the caddy tar file using xz +CADDY_COMPRESSED_FILE="docker/${CADDY_IMAGE_NAME}.tar.xz" +echo "Compressing the caddy image to $CADDY_COMPRESSED_FILE..." + +# Check if the compressed file exists and remove it +if [ -f "$CADDY_COMPRESSED_FILE" ]; then + echo "Removing existing compressed file $CADDY_COMPRESSED_FILE..." + rm "$CADDY_COMPRESSED_FILE" +fi + +# Proceed with compression for caddy +xz -z docker/${CADDY_IMAGE_NAME}.tar + +# Check if the compression was successful +if [ $? -ne 0 ]; then + echo "Error occurred while compressing the caddy Docker image" + docker buildx rm $BUILDER_NAME + exit 1 +fi + +echo "Caddy Docker image compressed successfully as $CADDY_COMPRESSED_FILE" # Remove the builder instance docker buildx rm $BUILDER_NAME -echo "Build process completed" +echo "Build process completed" \ No newline at end of file diff --git a/packages/reservation-platform/docker/caddy.tar.xz b/packages/reservation-platform/docker/caddy.tar.xz new file mode 100644 index 0000000..910cb83 Binary files /dev/null and b/packages/reservation-platform/docker/caddy.tar.xz differ diff --git a/packages/reservation-platform/docker/compose.yml b/packages/reservation-platform/docker/compose.yml index eb693fd..0b69309 100644 --- a/packages/reservation-platform/docker/compose.yml +++ b/packages/reservation-platform/docker/compose.yml @@ -1,6 +1,6 @@ services: caddy: - image: caddy + image: caddy:latest container_name: caddy restart: unless-stopped ports: diff --git a/packages/reservation-platform/docker/deploy_container.sh b/packages/reservation-platform/docker/deploy_container.sh index 0f87ef3..0375056 100755 --- a/packages/reservation-platform/docker/deploy_container.sh +++ b/packages/reservation-platform/docker/deploy_container.sh @@ -1,12 +1,25 @@ #!/bin/bash -# Load the Docker image from the tar file -echo "Loading Docker image from docker/myp-rp_latest.tar.xz..." +# Load the Docker images from the tar files +echo "Loading Docker images from tar files..." + +# Load myp-rp image +echo "Loading myp-rp image..." docker load -i "docker/myp-rp_latest.tar.xz" -# Check if loading the image was successful +# Check if loading the myp-rp image was successful if [ $? -ne 0 ]; then - echo "Error occurred while loading Docker image" + echo "Error occurred while loading myp-rp Docker image" + exit 1 +fi + +# Load caddy image +echo "Loading caddy image..." +docker load -i "docker/caddy.tar.xz" + +# Check if loading the caddy image was successful +if [ $? -ne 0 ]; then + echo "Error occurred while loading caddy Docker image" exit 1 fi diff --git a/packages/reservation-platform/docker/myp-rp_latest.tar.xz b/packages/reservation-platform/docker/myp-rp_latest.tar.xz index 979b6cc..9599311 100644 --- a/packages/reservation-platform/docker/myp-rp_latest.tar.xz +++ b/packages/reservation-platform/docker/myp-rp_latest.tar.xz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6006fefb3318a72c3b92570cc6b02914a23634bec6e04e416dc878f3ed4d9dc5 -size 284414424 +oid sha256:7985863a22c64d2d186e78d60364153d6b9b6f72510d077b020afe78944f5f8f +size 284435728