-
Notifications
You must be signed in to change notification settings - Fork 6
/
deploy_to_caprover.sh
executable file
·52 lines (44 loc) · 1.33 KB
/
deploy_to_caprover.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
#!/bin/bash
set -e
set -u
set -o pipefail
[ ! -f .env.server ] || export $(grep -v '^#' .env.server | xargs)
IS_BUILDING=true
IS_DEPLOYING_SERVER=true
IS_DEPLOYING_CLIENT=true
# Load env variables from .env.caprover
[ ! -f .env.caprover ] || export $(grep -v '^#' .env.caprover | xargs)
if [ "$IS_BUILDING" = true ] ; then
echo "Building server..."
wasp build
fi
if [ ! -d ".wasp/build" ] ; then
echo "Error: .wasp/build doesn't exist"
exit 1
fi
cd .wasp
if [ "$IS_DEPLOYING_SERVER" = true ] ; then
echo "Tar-ing server..."
tar -czf server.tar.gz --exclude "node_modules" ./build/*
echo "Deploying server..."
caprover deploy -a $SERVER_APP -t ./server.tar.gz -u $CAPROVER_URL -p $CAPROVER_PASSWORD
rm server.tar.gz
fi
if [ "$IS_DEPLOYING_CLIENT" = true ] ; then
echo "Building client..."
cd ./build/web-app
REACT_APP_API_URL=https://$SERVER_APP.apps.twoducks.dev npm run build
CLIENT_DOCKERFILE=$(cat <<EOF
FROM pierrezemb/gostatic
CMD [ "-fallback", "index.html", "-enable-logging"]
COPY ./build /srv/http
EOF
)
echo "$CLIENT_DOCKERFILE" > ./Dockerfile
echo "!build" > .dockerignore
echo "Tar-ing client..."
tar -czf ../../client.tar.gz --exclude "node_modules" ./*
echo "Deploying client..."
caprover deploy -a $CLIENT_APP -t ../../client.tar.gz -u $CAPROVER_URL -p $CAPROVER_PASSWORD
rm ../../client.tar.gz
fi