-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-image.sh
More file actions
executable file
·52 lines (39 loc) · 1.68 KB
/
build-image.sh
File metadata and controls
executable file
·52 lines (39 loc) · 1.68 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# This script builds the Docker container for this project and tags them
#!/usr/bin/env bash
set -e
source ./.env
# Check for env variables (DOCKER_REGISTRY, DOCKER_REPOSITORY)
if [ -z "$DOCKER_REGISTRY" ]; then
read -p "Enter Docker registry (e.g., docker.io): " DOCKER_REGISTRY
export DOCKER_REGISTRY
fi
if [ -z "$DOCKER_REPOSITORY" ]; then
read -p "Enter Docker repository (e.g., myusername/myrepository): " DOCKER_REPOSITORY
export DOCKER_REPOSITORY
fi
# attempt to eval flake for version
if [ -z "$VERSION" ]; then
VERSION=$(nix eval --raw .#packages.x86_64-linux.default.version 2>/dev/null || true)
if [ -z "$VERSION" ]; then
echo "Unable to eval version from flake, please set VERSION manually."
read -p "Enter version (e.g., 1.0.0): " VERSION
else
echo "Using version: $VERSION"
fi
export VERSION
fi
echo "Building Images with the following parameters:"
echo "DOCKER_REGISTRY=$DOCKER_REGISTRY"
echo "DOCKER_REPOSITORY=$DOCKER_REPOSITORY"
echo "VERSION=$VERSION"
# Build the Docker image
docker build -t "$DOCKER_REGISTRY/$DOCKER_REPOSITORY/tablo-full:$VERSION" -f dev.Dockerfile .
# Tag the image with latest
docker tag "$DOCKER_REGISTRY/$DOCKER_REPOSITORY/tablo-full:$VERSION" "$DOCKER_REGISTRY/$DOCKER_REPOSITORY/tablo-full:latest"
# Push the image to the registry
docker push "$DOCKER_REGISTRY/$DOCKER_REPOSITORY/tablo-full:$VERSION"
docker push "$DOCKER_REGISTRY/$DOCKER_REPOSITORY/tablo-full:latest"
echo "Docker images built and pushed successfully!"
# Save the image to a tar file
docker save "$DOCKER_REGISTRY/$DOCKER_REPOSITORY/tablo-full:$VERSION" -o "outputs/docker/tablo-full-$VERSION.tar"
echo "Docker image saved to outputs/docker/tablo-full-$VERSION.tar"