forked from MarquezProject/marquez
-
Notifications
You must be signed in to change notification settings - Fork 0
/
up.sh
executable file
·151 lines (138 loc) · 3.71 KB
/
up.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
#
# Copyright 2018-2023 contributors to the Marquez project
# SPDX-License-Identifier: Apache-2.0
#
# Usage: $ ./up.sh [FLAGS] [ARG...]
set -e
# Version of Marquez
readonly VERSION=0.47.0
# Build version of Marquez
readonly BUILD_VERSION=0.47.0
title() {
echo -e "\033[1m${1}\033[0m"
}
usage() {
echo "usage: ./$(basename -- ${0}) [FLAGS] [ARG...]"
echo "A script used to run Marquez via Docker"
echo
title "EXAMPLES:"
echo " # Build image from source"
echo " $ ./up.sh --build"
echo
echo " # Build image from source, then seed HTTP API server with metadata"
echo " $ ./up.sh --build --seed"
echo
echo " # Use tagged image"
echo " ./up.sh --tag X.Y.X"
echo
echo " # Use tagged image, then seed HTTP API server with metadata"
echo " ./up.sh --tag X.Y.X --seed"
echo
echo " # Set HTTP API server port"
echo " ./up.sh --api-port 9000"
echo
title "ARGUMENTS:"
echo " -a, --api-port int api port (default: 5000)"
echo " -m, --api-admin-port int api admin port (default: 5001)"
echo " -w, --web-port int web port (default: 3000)"
echo " -t, --tag string docker image tag (default: ${VERSION})"
echo " --args string docker arguments"
echo
title "FLAGS:"
echo " -b, --build build images from source"
echo " -s, --seed seed HTTP API server with metadata"
echo " -d, --detach run in the background"
echo " --no-web don't start the web UI"
echo " --no-volumes don't create volumes"
echo " -h, --help show help for script"
echo
}
# Change working directory to project root
project_root=$(git rev-parse --show-toplevel)
cd "${project_root}/"
# Base docker compose file
compose_files="-f docker-compose.yml"
# Default args
API_PORT=5000
API_ADMIN_PORT=5001
WEB_PORT=3000
POSTGRES_PORT=5432
NO_WEB="false"
NO_VOLUMES="false"
TAG="${VERSION}"
BUILD="false"
compose_args="-V --force-recreate --remove-orphans"
# Parse args
while [ $# -gt 0 ]; do
case $1 in
-a|'--api-port')
shift
API_PORT="${1}"
;;
-m|'--api-admin-port')
shift
API_ADMIN_PORT="${1}"
;;
-w|'--web-port')
shift
WEB_PORT="${1}"
;;
-p|'--pg-port')
shift
POSTGRES_PORT="${1}"
;;
-t|'--tag')
shift
TAG="${1}"
;;
--args)
shift
compose_args+=" ${1}"
;;
-b|'--build')
BUILD='true'
TAG="${BUILD_VERSION}"
;;
-s|'--seed')
SEED='true'
;;
-d|'--detach') DETACH='true' ;;
--no-web) NO_WEB='true' ;;
--no-volumes) NO_VOLUMES='true' ;;
-h|'--help')
usage
exit 0
;;
*) usage
exit 1
;;
esac
shift
done
# Enable detach mode to run containers in background
if [[ "${DETACH}" = "true" ]]; then
compose_args+=" --detach"
fi
# Enable starting HTTP API server with sample metadata
if [[ "${SEED}" = "true" ]]; then
compose_files+=" -f docker-compose.seed.yml"
fi
# Enable building from source
if [[ "${BUILD}" = "true" ]]; then
compose_files+=" -f docker-compose.dev.yml"
compose_args+=" --build"
fi
# Enable web UI
if [[ "${NO_WEB}" = "false" ]]; then
compose_files+=" -f docker-compose.web.yml"
# Enable building web UI from source
[[ "${BUILD}" = "true" ]] && compose_files+=" -f docker-compose.web-dev.yml"
fi
# Create docker volumes for Marquez
if [[ "${NO_VOLUMES}" = "false" ]]; then
./docker/volumes.sh marquez
fi
# Run docker compose cmd with overrides
DOCKER_SCAN_SUGGEST="false" API_PORT=${API_PORT} API_ADMIN_PORT=${API_ADMIN_PORT} WEB_PORT=${WEB_PORT} POSTGRES_PORT=${POSTGRES_PORT} TAG=${TAG} \
docker --log-level ERROR compose $compose_files up $compose_args