-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-build.sh
executable file
·58 lines (48 loc) · 1.32 KB
/
docker-build.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
set -eo pipefail
# Import common functions
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=./common.sh
source "$DIR/common.sh"
USAGE="Usage: $0 [OPTIONS]
Build Docker image.
OPTIONS: All options are optional
-h | --help
Display these instructions.
-v | --verbose
Display commands being executed."
while [ $# -gt 0 ]; do
case "$1" in
-h | --help)
print_usage_and_exit
;;
-v | --verbose)
set -x
;;
esac
shift
done
cd "$REPO_ROOT"
DOCKER_IMAGE="axum-runtime"
GIT_HASH=$(git rev-parse --short HEAD)
TIMESTAMP=$(date "+%Y-%m-%d")
TAG="${TIMESTAMP}-${GIT_HASH}"
if ! docker info > /dev/null 2>&1; then
if [ "$BASH_PLATFORM" = mac ]; then
print_yellow "Docker does not seem to be running. Starting Docker..."
open -a Docker.app
sleep 10
if ! docker info > /dev/null 2>&1; then
print_error_and_exit "Timed out waiting for Docker to start..."
fi
else
print_error_and_exit "Docker does not seem to be running. Start Docker first..."
fi
fi
print_magenta "Building Docker image..."
docker build \
--pull \
--build-arg DEPLOYMENT_TAG="$TAG" \
--tag "$DOCKER_IMAGE":latest \
--target "$DOCKER_IMAGE" \
--file Dockerfile .