Skip to content

Instantly share code, notes, and snippets.

@Mohammad-Reihani
Created July 31, 2025 16:56
Show Gist options
  • Save Mohammad-Reihani/e720ff6cf0b8af33dc8efa4260bfc3ad to your computer and use it in GitHub Desktop.
Save Mohammad-Reihani/e720ff6cf0b8af33dc8efa4260bfc3ad to your computer and use it in GitHub Desktop.
Build docker image and save
#!/bin/bash
# === Configuration ===
IMAGE_NAME="react-native-android-builder"
IMAGE_TAG="latest"
IMAGE_FILE="$IMAGE_NAME.tar.xz"
DOCKERFILE_PATH="Dockerfile"
BUILD_CONTEXT="."
# === Build ===
echo "πŸ”§ Building Docker image: $IMAGE_NAME:$IMAGE_TAG ..."
docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f "$DOCKERFILE_PATH" "$BUILD_CONTEXT"
# === Save and Compress ===
echo "πŸ“¦ Saving and compressing Docker image to $IMAGE_FILE ..."
echo "⏳ This might take a while depending on the image size and disk speed."
echo "πŸ’‘ Please DO NOT interrupt the process. It's still running unless an error appears."
echo "πŸ“ You can monitor the file size with: ls -lh $IMAGE_FILE"
docker save "$IMAGE_NAME:$IMAGE_TAG" | xz -T0 -c > "$IMAGE_FILE"
# === Done ===
echo "βœ… Docker image saved and compressed successfully: $IMAGE_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment