-
Notifications
You must be signed in to change notification settings - Fork 15
/
setup.sh
executable file
·93 lines (73 loc) · 3.58 KB
/
setup.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
#!/usr/bin/env bash
set -ex
requiredEnv=$(grep -p "^export" < $(dirname $0)/envs-example.sh | sed 's/export \([^=]*\)=.*/\1/')
for envVar in $requiredEnv; do
if [ -z $(printenv $envVar) ] ; then
echo "missing environment variable \"$envVar\" , have you followed the setup instructions?"
echo "required variables are $requiredEnv"
exit 1
fi
done
APP=${APP:-vista}
export APP
if [ $VISTA_MODE = flow ] ; then
echo "Running in flow mode , unset VISTA_MODE to run async and rerun setup to deploy async "
else
echo "Running in async mode , set VISTA_MODE to 'flow' and rerun setup to deploy in flow mode "
export VISTA_MODE="async"
fi
DOCKER_LOCALHOST=${DOCKER_LOCALHOST:-docker.for.mac.localhost}
echo "Setting up app: $APP with docker localhost $DOCKER_LOCALHOST"
# Get rid of any existing minio
docker rm -f minio1 || true
sed -e "s/APP/$APP/" -e "s/DOCKER_LOCALHOST/$DOCKER_LOCALHOST/" < $PWD/scripts/minio_config.json.tmpl > $PWD/scripts/minio_config.json
# if we want to save data outside of container, add this into line below: -v /tmp/export/minio1:/export
docker run -d -p 9000:9000 --rm --name minio1 \
-e "MINIO_ACCESS_KEY=$STORAGE_ACCESS_KEY" \
-e "MINIO_SECRET_KEY=$STORAGE_SECRET_KEY" \
-v $PWD/scripts/minio_config.json:/root/.minio/config.json minio/minio server /export
sleep 5
docker run --rm -v $PWD:/mc -w /mc --entrypoint=/bin/sh -e DEMOACCESSKEY=$STORAGE_ACCESS_KEY -e DEMOSECRETKEY=$STORAGE_SECRET_KEY -e DOCKER_LOCALHOST -e VISTA_MODE minio/mc scripts/setup_minio.sh
pushd scripts
if [ $VISTA_MODE = flow ]; then
./setup_flow.sh
fi
popd
# we need to have a publish function in place before starting minio, so deploy first
# time="2017-08-30T16:21:13Z" level=error msg="Initializing object layer failed" cause="Unable to initialize event notification. Unexpected response from webhook server http://docker.for.mac.localhost:8080/r/myapp/publish: (404 Not Found)" source="[server-main.go:206:serverMain()]"
cd services
if [[ "$1" == "local" ]]; then
echo "Deploying local only"
fn --verbose deploy --all --app vista --local --no-bump \
--build-arg TWITTER_CONF_KEY=${TWITTER_CONF_KEY} \
--build-arg TWITTER_CONF_SECRET=${TWITTER_CONF_SECRET} \
--build-arg TWITTER_TOKEN_KEY=${TWITTER_TOKEN_KEY} \
--build-arg TWITTER_TOKEN_SECRET=${TWITTER_TOKEN_SECRET} \
--build-arg STORAGE_ACCESS_KEY=${STORAGE_ACCESS_KEY} \
--build-arg STORAGE_SECRET_KEY=${STORAGE_SECRET_KEY} \
--build-arg MINIO_SERVER_URL=${MINIO_SERVER_URL} \
--build-arg PUBNUB_SUBSCRIBE_KEY=${PUBNUB_SUBSCRIBE_KEY} \
--build-arg PUBNUB_PUBLISH_KEY=${PUBNUB_PUBLISH_KEY} \
--build-arg STORAGE_BUCKET=${STORAGE_BUCKET} \
--build-arg FLICKR_API_KEY=${FLICKR_API_KEY} \
--build-arg FLICKR_API_SECRET=${FLICKR_API_SECRET}
else
fn --verbose deploy --all --app vista \
--build-arg TWITTER_CONF_KEY=${TWITTER_CONF_KEY} \
--build-arg TWITTER_CONF_SECRET=${TWITTER_CONF_SECRET} \
--build-arg TWITTER_TOKEN_KEY=${TWITTER_TOKEN_KEY} \
--build-arg TWITTER_TOKEN_SECRET=${TWITTER_TOKEN_SECRET} \
--build-arg STORAGE_ACCESS_KEY=${STORAGE_ACCESS_KEY} \
--build-arg STORAGE_SECRET_KEY=${STORAGE_SECRET_KEY} \
--build-arg MINIO_SERVER_URL=${MINIO_SERVER_URL}\
--build-arg PUBNUB_SUBSCRIBE_KEY=${PUBNUB_SUBSCRIBE_KEY} \
--build-arg PUBNUB_PUBLISH_KEY=${PUBNUB_PUBLISH_KEY} \
--build-arg STORAGE_BUCKET=${STORAGE_BUCKET} \
--build-arg FLICKR_API_KEY=${FLICKR_API_KEY} \
--build-arg FLICKR_API_SECRET=${FLICKR_API_SECRET}
fi
cd ..
pushd scripts
./setenv.sh
popd
docker run --rm -v $PWD:/tmp -w /tmp -e PUBNUB_SUBSCRIBE_KEY treeder/temple public/vista.erb public/vista.html