Skip to content

Commit b0d510c

Browse files
dolfinuswslulciuc
andauthored
Improve down.sh script (#2778)
Signed-off-by: Martynov Maxim <martinov_m_s_@mail.ru> Co-authored-by: Willy Lulciuc <willy@datakin.com>
1 parent a3c2d6e commit b0d510c

2 files changed

Lines changed: 26 additions & 21 deletions

File tree

docker/down.sh

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright 2018-2023 contributors to the Marquez project
44
# SPDX-License-Identifier: Apache-2.0
55
#
6-
# Usage: $ ./down.sh
6+
# Usage: $ ./down.sh [FLAGS]
77

88
set -e
99

@@ -12,16 +12,29 @@ title() {
1212
}
1313

1414
usage() {
15-
echo "usage: ./$(basename -- ${0})"
15+
echo "usage: ./$(basename -- ${0}) [FLAGS]"
1616
echo "A script used to bring down Marquez when run via Docker"
1717
echo
18+
title "EXAMPLES:"
19+
echo " # Stop and remove all containers"
20+
echo " $ ./down.sh"
21+
echo
22+
echo " # Stop and remove all containers, remove volumes"
23+
echo " $ ./down.sh -v"
24+
echo
25+
title "FLAGS:"
26+
echo " -v, --volumes remove created volumes"
27+
echo " -h, --help show help for script"
28+
echo
1829
}
1930

2031
# Change working directory to project root
2132
project_root=$(git rev-parse --show-toplevel)
2233
cd "${project_root}/"
2334

2435
compose_files="-f docker-compose.yml"
36+
37+
# Default args
2538
compose_args="--remove-orphans"
2639

2740
# Parse args
@@ -31,22 +44,14 @@ while [ $# -gt 0 ]; do
3144
usage
3245
exit 0
3346
;;
47+
-v|'--volumes')
48+
compose_args+=" -v"
49+
;;
3450
esac
3551
shift
3652
done
3753

3854
# We can ignore the tag and port(s) when cleaning up running
3955
# containers and volumes
40-
TAG=any
41-
42-
API_PORT=${RANDOM}
43-
API_ADMIN_PORT=${RANDOM}
44-
WEB_PORT=${RANDOM}
45-
TAG=${RANDOM}
46-
47-
docker compose $compose_files down $compose_args
48-
49-
docker volume rm marquez_data && \
50-
docker volume rm marquez_db-backup && \
51-
docker volume rm marquez_db-conf && \
52-
docker volume rm marquez_db-init
56+
API_PORT=${RANDOM} API_ADMIN_PORT=${RANDOM} WEB_PORT=${RANDOM} TAG=${RANDOM} \
57+
docker compose $compose_files down $compose_args

docker/up.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ usage() {
5050
echo " --no-web don't start the web UI"
5151
echo " --no-volumes don't create volumes"
5252
echo " -h, --help show help for script"
53-
exit 1
53+
echo
5454
}
5555

5656
# Change working directory to project root
@@ -68,7 +68,7 @@ NO_WEB="false"
6868
NO_VOLUMES="false"
6969
TAG="${VERSION}"
7070
BUILD="false"
71-
ARGS="-V --force-recreate --remove-orphans"
71+
compose_args="-V --force-recreate --remove-orphans"
7272
# Parse args
7373
while [ $# -gt 0 ]; do
7474
case $1 in
@@ -90,7 +90,7 @@ while [ $# -gt 0 ]; do
9090
;;
9191
--args)
9292
shift
93-
ARGS+=" ${1}"
93+
compose_args+=" ${1}"
9494
;;
9595
-b|'--build')
9696
BUILD='true'
@@ -115,7 +115,7 @@ done
115115

116116
# Enable detach mode to run containers in background
117117
if [[ "${DETACH}" = "true" ]]; then
118-
ARGS+=" --detach"
118+
compose_args+=" --detach"
119119
fi
120120

121121
# Enable starting HTTP API server with sample metadata
@@ -126,7 +126,7 @@ fi
126126
# Enable building from source
127127
if [[ "${BUILD}" = "true" ]]; then
128128
compose_files+=" -f docker-compose.dev.yml"
129-
ARGS+=" --build"
129+
compose_args+=" --build"
130130
fi
131131

132132
# Enable web UI
@@ -143,4 +143,4 @@ fi
143143

144144
# Run docker compose cmd with overrides
145145
DOCKER_SCAN_SUGGEST="false" API_PORT=${API_PORT} API_ADMIN_PORT=${API_ADMIN_PORT} WEB_PORT=${WEB_PORT} TAG=${TAG} \
146-
docker --log-level ERROR compose $compose_files up $ARGS
146+
docker --log-level ERROR compose $compose_files up $compose_args

0 commit comments

Comments
 (0)