-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun-build-image.sh
executable file
·56 lines (48 loc) · 1.08 KB
/
run-build-image.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
#!/bin/bash
set -eu
SCRIPT_DIR=$(
cd $(dirname $0)
pwd
) # without ending /
cd ${SCRIPT_DIR}
function usage() { echo "Usage: $(basename $0) <build|build-no-cache|test|push|rmi> [tag = current branch] [message]" && exit 1; }
[ $# -lt 1 ] && usage
repo=dodopizza/mysql-data-mover
current_branch=$(git branch | grep \* | cut -d ' ' -f2)
action=${1:-'build'}
tag=${2:-${current_branch}}
message=${1:-"${tag}"}
echo "[~] Tag '${tag}'"
case "${action}" in
build)
DOCKER_BUILDKIT=1 docker build --rm \
--progress=plain \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from ${repo}:cache__ \
--tag ${repo}:${tag} \
--tag ${repo}:cache__ \
--file Dockerfile \
.
;;
build-no-cache)
DOCKER_BUILDKIT=1 docker build --rm \
--progress=plain \
--no-cache \
--tag ${repo}:${tag} \
--file Dockerfile \
.
;;
push)
docker push ${repo}:${tag}
;;
test)
docker run -it --rm ${repo}:${tag}
;;
rmi)
docker rmi -f ${repo}:${tag}
;;
*)
usage
;;
esac
echo "[.] All Done"