This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compose-etl
executable file
·88 lines (76 loc) · 3.17 KB
/
compose-etl
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
#!/bin/bash
# Fail on error, so this script can be chained safely:
set -e
# Need at least three args and the first argument to be the site:
if [ $# -lt 3 ] || ! { [ $1 = "ada" ] || [ $1 = "phy" ]; }; then
echo "Usage: compose-etl [ada|phy] [APP_VERSION] [DOCKER_ARGS]..."
echo "Note this is the app version and not the API version!"
exit 1
fi
# Extract args:
SITE=$1
APP_VERSION=$2
ENV=live
# We're done with the first two args. The remainder will be passed to docker-compose:
shift 2
# Use the app image to find the correct API version to use:
if [ $1 = "create" ] || [ $1 = "pull" ] || [ $1 = "push" ] || [ $1 = "run" ] || [ $1 = "start" ] || [ $1 = "up" ]; then
# This will cause new containers or should update containers, so pull newer images if possible:
docker pull docker.isaacscience.org/isaac-$SITE-app:$APP_VERSION
API_VERSION=$(docker inspect -f '{{.Config.Labels.apiVersion}}' docker.isaacscience.org/isaac-$SITE-app:$APP_VERSION)
docker pull docker.isaacscience.org/isaac-etl:$API_VERSION
elif [ $1 = "down" ] || [ $1 = "stop" ] || [ $1 = "restart" ] || [ $1 = "exec" ] || [ $1 = "config" ] || [ $1 = "logs" ] || [ $1 = "kill" ] || [ $1 = "ps" ]; then
# This affects existing containers, so don't pull newer images:
API_VERSION=$(docker inspect -f '{{.Config.Labels.apiVersion}}' docker.isaacscience.org/isaac-$SITE-app:$APP_VERSION)
else
# This might not be a docker-compose operation. If it is, it could be added above to the correct branch.
echo "Error: Unsupported docker-compose operation '$1'!"
exit 1
fi
# Ensure we actually _have_ an API_VERSION before we continue, though the "set -e" might avoid this:
if [ -z $API_VERSION ]; then
echo "Error: Cannot extract API version from APP image!"
exit 1
fi
ETL_NAME=$SITE-etl-$API_VERSION
ES_CONTAINER=$SITE-elasticsearch-live
# The content repo is named differently for both sites in a non-standard way:
if [ "$SITE" == "ada" ]; then
CONTENT_REPO="ada-content"
elif [ "$SITE" == "phy" ]; then
CONTENT_REPO="rutherford-content"
fi
docker-compose -p dc-$SITE-etl -f - $@ << EOF
version: '2'
services:
$SITE-etl:
container_name: $ETL_NAME
image: docker.isaacscience.org/isaac-etl:$API_VERSION
environment:
- SEGUE_CONFIG_LOCATION=/local/data/conf/segue-config.properties
- JAVA_OPTIONS=-Dlog.path=/isaac-logs -Dsegue.version=$API_VERSION -Djetty.port=8090
volumes:
- /local/data/m2:/root/.m2:rw
- /local/data/isaac-config/$SITE/segue-config.$ENV.properties:/local/data/conf/segue-config.properties:ro
- /local/data/isaac-config/$SITE/content_indices.properties:/local/data/conf/content_indices.properties:rw
- /local/data/$CONTENT_REPO:/local/data/$CONTENT_REPO:rw
- /local/data/keys:/local/data/keys:ro
- /local/data/school_list_2019.csv:/local/data/school_list_2019.csv:ro
- /local/data/school_list_2022.csv:/local/data/school_list_2022.csv:ro
- /var/log/isaac/$SITE-etl:/isaac-logs:rw
external_links:
- $ES_CONTAINER:elasticsearch
networks:
default:
aliases:
- $SITE-etl
logging:
driver: journald
options:
tag: $SITE-isaac-etl
networks:
default:
external:
name: isaac
EOF
exit 0