-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_docker.sh
More file actions
58 lines (51 loc) · 1.25 KB
/
build_docker.sh
File metadata and controls
58 lines (51 loc) · 1.25 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
53
54
55
56
57
58
#!/usr/bin/env sh
# Check for flags
LOCAL=false; REMOTE=false
for arg in "$@"; do
case "$arg" in
--local)
LOCAL=true
break
;;
--remote)
REMOTE=true
break
;;
esac
done
# Set default local values
if [ "$REMOTE" = 'false' ]; then
ORGANIZATION=${ORGANIZATION:-$(basename "$(realpath ..)")}
REPO_NAME=${REPO_NAME:-$(basename "$(realpath .)")}
VERSION=${VERSION:-"development"}
fi
# Prompt the user for input if not forced (i.e. 'local' or 'remote')
if [ "$LOCAL" = 'false' && "$REMOTE" == 'false' ]; then
echo "Organization (default: $ORGANIZATION):"
read input
ORGANIZATION=${input:-$ORGANIZATION}
echo "Repository (default: $REPO_NAME):"
read input
REPO_NAME=${input:-$REPO_NAME}
echo "Version (default: development)"
read input
VERSION=${input:-'development'}
else
if [ -e "$(dirname "$0")/../.env" ]; then
. "$(dirname "$0")/../.env"
fi
fi
# Fix for \r tag issues
if [ "$VERSION" != 'development' ]; then
VERSION=$(echo "$VERSION" | tr -d '\r')
fi
# Local Docker build command
if [ "$REMOTE" = 'false' ]; then
IMAGE_NAME=${IMAGE_NAME:-"$ORGANIZATION/$REPO_NAME"}
docker buildx build \
-f docker/Dockerfile \
--rm \
--build-arg VERSION="$VERSION" \
-t "$IMAGE_NAME:$VERSION" \
.
fi