-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·57 lines (43 loc) · 1.37 KB
/
deploy.sh
File metadata and controls
executable file
·57 lines (43 loc) · 1.37 KB
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
#!/bin/bash
# We need the environment as well as the stack being deployed.
ENV=$1
STACK=$2
if [ -z "$ENV" ]; then
echo "usage: deploy.sh ENV STACK"
exit 2
fi
if [ -z "$STACK" ]; then
echo "usage: deploy.sh ENV STACK"
exit 2
fi
# These will rarely change.
export CARGO_HOME=~/.cargo
export PATH=$PATH:$CARGO_HOME/bin
export CERT=~/.ssh/deploy.pem
export PRIMARY_MIGRATIONS_PATH=~/dev-ops/deploy/primary
export TSDB_MIGRATIONS_PATH=~/dev-ops/deploy/tsdb
# Depends on environment and what's being deployed.
export ARCHIVE=~/dev-ops/deploy/${STACK}.tar
if [ "$ENV" == "prod" ]; then
export TERRAFORM_ENV=~/dev-ops/prod.json
export POLL_URL=https://api.fieldkit.org/status
else
export TERRAFORM_ENV=~/dev-ops/dev.json
export POLL_URL=https://api.fkdev.org/status
fi
# Warning: If you enable set -x then you will leak database passwords.
set -e
pushd ~/dev-ops
pushd deployer
cargo build --release -j 1
# Warning: If you enable set -x then you will leak database passwords.
MIGRATE_DATABASE_URL=`jq -r .database_url.value $TERRAFORM_ENV` MIGRATE_PATH=$PRIMARY_MIGRATIONS_PATH ~/dev-ops/deploy/migrate migrate
MIGRATE_DATABASE_URL=`jq -r .timescaledb_url.value $TERRAFORM_ENV` MIGRATE_PATH=$TSDB_MIGRATIONS_PATH ~/dev-ops/deploy/migrate migrate
cargo run --release -j 1 deploy \
--cert $CERT \
--terraform $TERRAFORM_ENV \
--archive $ARCHIVE \
--poll $POLL_URL
popd
popd
echo done