forked from MarquezProject/marquez
-
Notifications
You must be signed in to change notification settings - Fork 0
/
volumes.sh
executable file
·77 lines (62 loc) · 2.26 KB
/
volumes.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
#!/bin/bash
#
# Copyright 2018-2023 contributors to the Marquez project
# SPDX-License-Identifier: Apache-2.0
#
# Usage: $ ./volumes.sh <volume-prefix>
title() {
echo -e "\033[1m${1}\033[0m"
}
ls() {
docker run -it --rm -v "${1}:/tmp" busybox ls /tmp
}
usage() {
echo "usage: ./$(basename -- ${0}) <volume-prefix>"
echo "A script used to create persistent volumes for Marquez"
echo
title "EXAMPLE:"
echo " # Create volumes with prefix"
echo " $ ./volumes.sh my-volume-prefix"
exit 1
}
# Change working directory to project root
project_root=$(git rev-parse --show-toplevel)
cd "${project_root}/"
# Volume prefix for Marquez
volume_prefix="${1}"
# Ensure valid volume prefix
if [[ -z "${volume_prefix}" ]]; then
echo "Volume prefix must not be empty or blank!"
usage
fi
# Volumes with prefix
data_volume="${volume_prefix}_data"
db_conf_volume="${volume_prefix}_db-conf"
db_init_volume="${volume_prefix}_db-init"
db_backup_volume="${volume_prefix}_db-backup"
opensearch_volume="${volume_prefix}_opensearch-data"
echo "...creating volumes: ${data_volume}, ${db_conf_volume}, ${db_init_volume}, ${db_backup_volume} ${opensearch_volume}"
# Create persistent volumes for Marquez
docker volume create "${data_volume}" > /dev/null
docker volume create "${db_conf_volume}" > /dev/null
docker volume create "${db_init_volume}" > /dev/null
docker volume create "${db_backup_volume}" > /dev/null
docker volume create "${opensearch_volume}" > /dev/null
# Provision persistent volumes for Marquez
docker create --name volumes-provisioner \
-v "${data_volume}:/data" \
-v "${db_conf_volume}:/db-conf" \
-v "${db_init_volume}:/db-init" \
busybox > /dev/null 2>&1
# Add startup configuration for Marquez
docker cp ./docker/wait-for-it.sh volumes-provisioner:/data/wait-for-it.sh
echo "Added files to volume ${data_volume}: $(ls "${data_volume}")"
# Add db configuration
docker cp ./docker/postgresql.conf volumes-provisioner:/db-conf/postgresql.conf
echo "Added files to volume ${db_conf_volume}: $(ls "${db_conf_volume}")"
# Add db scripts
docker cp ./docker/init-db.sh volumes-provisioner:/db-init/init-db.sh
echo "Added files to volume ${db_init_volume}: $(ls "${db_init_volume}")"
# Delete volumes provisioner for Marquez
docker rm volumes-provisioner > /dev/null
echo "DONE!"