forked from nirdizati-research/predict-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
27 lines (20 loc) · 1.07 KB
/
Copy pathdeploy.sh
File metadata and controls
27 lines (20 loc) · 1.07 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
#!/bin/bash
set -o nounset
set -o errexit
# Unlock SSH private key using TRAVIS automatic encryption
# See https://docs.travis-ci.com/user/encrypting-files/#automated-encryption
openssl aes-256-cbc -K $encrypted_9b7253ae8d55_key -iv $encrypted_9b7253ae8d55_iv -in cloud.key.enc -out ./cloud.key -d
eval "$(ssh-agent -s)"
chmod 600 ./cloud.key
echo -e "Host ${SERVER_IP}\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
ssh-add ./cloud.key
# Open SSH tunnel to forward remote Docker socket to local docker.sock file
# SSH is put in control-socket mode, to close the connection when we have finished
ssh -M -S my-ctrl-socket -fnNT -o ExitOnForwardFailure=yes -L /tmp/docker.sock:/var/run/docker.sock ${SERVER_USER}@${SERVER_IP}
# Tell docker-compose to use the remote socket to talk to the DOcker daemon on the server
export DOCKER_HOST=unix:///tmp/docker.sock
docker-compose pull
# Start up the new containers
docker-compose up --detach --force-recreate react-client
# Close the SSH connection using the control socket opened previously
ssh -S my-ctrl-socket -O exit ${SERVER_USER}@${SERVER_IP}