-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathbuild_containers.sh
executable file
·60 lines (45 loc) · 2.38 KB
/
build_containers.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
#!/bin/bash
set -eu -o pipefail
BUILD_ALL=${BUILD_ALL:=0}
BUILD_NUMBER=${BUILD_NUMBER:=1}
TAG=${TAG:-test}
PUBLISH_CONTAINERS=${PUBLISH_CONTAINERS:=1}
# Get an unique venv folder to use inside workspace
VENV=".venv-${BUILD_NUMBER}"
# Initialize new venv
python3 -m venv "${VENV}"
source "${VENV}/bin/activate"
# Update pip
pip3 install -U pip
pip3 install packaging
pip3 install -U setuptools
pip3 install -U pipenv
pipenv install --dev --system --deploy
FULL_VERSION_NUMBER="$(python3 setup.py --version)"
VERSION_NUMBER=$(echo "${FULL_VERSION_NUMBER}" | cut -d '+' -f 1)
if [ $PUBLISH_CONTAINERS -eq 1 ]; then
AWS_ACCOUNT_ID="$(aws sts get-caller-identity --output=text --query "Account")"
eval "$(aws ecr get-login --no-include-email --region us-east-1)"
fi
python3 setup.py build
docker build -t concordia .
if [ $PUBLISH_CONTAINERS -eq 1 ]; then
docker tag concordia:latest "${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/concordia:${VERSION_NUMBER}"
docker tag concordia:latest "${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/concordia:${TAG}"
docker push "${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/concordia:${VERSION_NUMBER}"
docker push "${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/concordia:${TAG}"
fi
if [ $BUILD_ALL -eq 1 ]; then
docker build -t concordia/importer --file importer/Dockerfile .
docker build -t concordia/celerybeat --file celerybeat/Dockerfile .
if [ $PUBLISH_CONTAINERS -eq 1 ]; then
docker tag concordia/importer:latest "${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/concordia/importer:${VERSION_NUMBER}"
docker tag concordia/importer:latest "${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/concordia/importer:${TAG}"
docker push "${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/concordia/importer:${VERSION_NUMBER}"
docker push "${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/concordia/importer:${TAG}"
docker tag concordia/celerybeat:latest "${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/concordia/celerybeat:${VERSION_NUMBER}"
docker tag concordia/celerybeat:latest "${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/concordia/celerybeat:${TAG}"
docker push "${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/concordia/celerybeat:${VERSION_NUMBER}"
docker push "${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/concordia/celerybeat:${TAG}"
fi
fi