Skip to content

Commit b681dab

Browse files
author
matthias_schaub
committed
Add documentation on deployment.
1 parent 5a0e2d0 commit b681dab

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,20 @@ script:
3939
- docker-compose run mapswipe_workers python -m unittest discover --verbose --start-directory tests/integration/
4040

4141
after_success:
42-
# Deploy to development server using Ansible
4342
# SSH setup to deploy to server after build.
4443
- apk add openssh-client
45-
- eval "$(ssh-agent -s)" #start the ssh agent
44+
- eval "$(ssh-agent -s)" # start the ssh agent
4645
- mkdir -p $HOME/.ssh
47-
# - chmod 700 $HOME/.ssh
46+
# Use config to define SSH connection variables (User, IdentityFile)
4847
- cp travis/ssh_config $HOME/.ssh/config
4948
- openssl aes-256-cbc -K $encrypted_c17fa81e6490_key -iv $encrypted_c17fa81e6490_iv -in travis/ssh-private-key.enc -out $HOME/.ssh/private-key -d
5049
- chmod 600 $HOME/.ssh/private-key
5150
- ssh-add $HOME/.ssh/private-key
5251
- chmod +x deploy.sh
5352

5453
deploy:
54+
# Deploy to server using Ansible
5555
provider: script
56-
# Extent waiting time of Travis for deploy to to finish
5756
script: bash deploy.sh
5857
on:
5958
branch: dev

deploy.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/bash
2-
# Deploy to dev server.
2+
# Deploy to server.
33
# This script is called by Travis.
44

55
function bell() {
6+
# Print regular to stdout, so that Travis will not abort due to time.
7+
# travis_wait does not work with script deployment.
68
while true; do
79
echo -e "\a"
810
sleep 60
@@ -12,4 +14,4 @@ bell &
1214

1315
ansible-playbook -i ansible/inventory.yml ansible/playbook.yml
1416

15-
exit $?
17+
exit $? # Return exit code of last command

docs/source/contributing.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,10 @@ From now on `black`, `flake8` and `isort` should run automatically whenever `git
3434

3535
When running those tools manually please make sure the right version is used. The version can be looked up in `.pre-commit-config.yaml`.
3636
To update to newer version please make sure to change version numbers in `.pre-commit-config.yaml`, `.travis.yml` and `requirements.txt`.
37+
38+
39+
### Tips
40+
41+
Ignore a hook: `SKIP=flake8 git commit -m "foo"`
42+
Mark in code that flake8 should ignore the line: `print() # noqa`
43+

docs/source/deployment_overview.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@ MapSwipe utilizes a bunch of Google Cloud services:
1616
[Configuration](configuration.md) describes all needed configuration and credentials.
1717

1818
[Installation](installation.md) describes step-by-step how to setup the backend for the first time.
19+
20+
21+
## Continuous deployment using Ansible and Travis
22+
23+
Travis is setup to automatically deploy a new version of MapSwipe Back-End to the server once it run successfully.
24+
This is done by using Travis script deployment (https://docs.travis-ci.com/user/deployment/script/). Travis simply calls the `deploy.sh` script found at the root directory of MapSwipe Workers.
25+
To be able to connect to the MapSwipe server the Travis instance uses an encrypted SSH private key (Which can be found in the directory `travis/`).
26+
27+
In the `deploy.sh` script an Ansible Playbook is run (https://docs.ansible.com/ansible/latest/index.html). Ansible is an automation tool which utilizes a SSH connection (`ansible/ansible.cfg`) to run commands defined in the Playbook (`ansible/playbook.yml`) on hosts defined in the Inventory (`ansible/inventory.yml`).

0 commit comments

Comments
 (0)