-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdo_save.sh
37 lines (26 loc) · 1.18 KB
/
do_save.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
# Stop at first error
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# Set default container name
DOCKER_IMAGE_TAG="luna25-evaluation-open-development-phase"
# Check if an argument is provided
if [ "$#" -eq 1 ]; then
DOCKER_IMAGE_TAG="$1"
fi
echo "=+= (Re)build the container"
source "${SCRIPT_DIR}/do_build.sh" "$DOCKER_IMAGE_TAG"
# Get the build information from the Docker image tag
build_timestamp=$( docker inspect --format='{{ .Created }}' "$DOCKER_IMAGE_TAG")
if [ -z "$build_timestamp" ]; then
echo "Error: Failed to retrieve build information for container $DOCKER_IMAGE_TAG"
exit 1
fi
# Format the build information to remove special characters
formatted_build_info=$(echo $build_timestamp | sed -E 's/(.*)T(.*)\..*Z/\1_\2/' | sed 's/[-,:]/-/g')
# Set the output filename with timestamp and build information
output_filename="${SCRIPT_DIR}/${DOCKER_IMAGE_TAG}_${formatted_build_info}.tar.gz"
# Save the Docker container and gzip it
echo "Saving the container as ${output_filename}. This can take a while."
docker save "$DOCKER_IMAGE_TAG" | gzip -c > "$output_filename"
echo "Container saved as ${output_filename}"