-
Notifications
You must be signed in to change notification settings - Fork 4
Deployment
In order to deploy this project you need to a have a system with docker and docker-compose available and optionally a job scheduler such as Vixie Cron for the ability to automatically start and update the docker container images. Also Nginx or Apache is required for the intended use case, of which, only Nginx examples are provided.
Dockerhub builds automatically the frontend and backend images for both master and dev branches with tags production and dev respectively. These autobuilds are done regardless of the results in Travis builds.
Since our project codebase is organized by having master, dev and feature branches where features are merged into dev via pull requests, which are, reviewed by peers, and successively the dev branch into master under supervision, there is not a high likelihood for serious errors hitting the master branch. Hence, there is not currently any need for a more sophisticated build chain (e.g. building the docker container images in Travis and pushing them to Dockerhub, that is, only if the prior tests pass).
Current actual working docker-compose.yml file without the TOKEN value:
version: '2'
services:
web:
environment:
- BACKEND_LOGIN_URL=https://svm-61.cs.helsinki.fi/labtool-backend/login
- PUBLIC_URL=https://svm-61.cs.helsinki.fi/labtool/
- NODE_ENV=production
image: labtool/labtool:test
ports:
- "6000:3000"
depends_on:
- backend
- db
backend:
environment:
- TOKEN=<CHANGEME>
- NODE_ENV=production
image: labtool/labtool-backend:test
ports:
- "6001:3001"
depends_on:
- db
db:
environment:
PGDATA: /data/pg10.1_labtool_2018k
volumes:
- /data/pg10.1_labtool_2018k:/data/pg10.1_labtool_2018k
image: postgres:10.1
restart: unless-stopped*note that in this example we are choosing test tag from both frontend and backend tags.
Make sure that the update.sh is executable by your systems super user. This because super user privileges are a requirement for running docker containers.
#!/bin/sh
PATH=/usr/local/bin:/usr/sbin:/usr/sbin:/usr/bin:/sbin:/bin
# CHANGE ME
DOCKER_COMPOSE_YML_DIR=/root/ohtuprojekti_2018k
cd $DOCKER_COMPOSE_YML_DIR
DCOMPOSE=`which docker-compose`
$DCOMPOSE down
$DCOMPOSE pull
$DCOMPOSE up
Crontab lines in this case to start at system startup and daily at 4 AM restart with automatic update:
@reboot /root/ohtuprojekti_2018k/update.sh >/dev/null 2>&1
0 4 * * * /root/ohtuprojekti_2018k/update.sh >/dev/null 2>&1under http server create two locations as following:
location /labtool/ {
proxy_pass http://localhost:6000/;
}
location /labtool-backend/ {
proxy_pass http://localhost:6001/;
}The above configuration is subject to change.
Work in launch sequence and ready to explode. Either official SSL certificates for yet nonexistent CNAMEs or letsencrypt free 90d certificates.