Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions GCP-WATCHTWER-DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# OnTrack Deployment on GCP with Watchtower

Watchtower is a container based solution for automating docker container base image updates.
[Watchtower Documentation](https://containrrr.dev/watchtower/)

## Steps

1. Create a VM within GCP Compute Engine section
2. ssh into machine
3. Update machine `sudo apt update && sudo apt upgrade -y`
4. Install Docker by following the steps to install docker and docker compose with the convenience script on at [this link](https://docs.docker.com/engine/install/debian/#install-using-the-convenience-script).
5. Follow the steps in the DEPLOYING.md file to complete the setup but instead of using the `docker compose up` command use the `docker compose -f docker-compose-watchtower.yml up`.
97 changes: 97 additions & 0 deletions production/docker-compose-watchtower.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
version: '3.8'

networks:
backnet:
frontnet:

services:

# This is the proxy which receives all http requests and forwards to relevant servers.
proxy:
image: nginx:mainline-alpine
container_name: proxy
ports:
- 80:80
- 443:443
depends_on:
- webserver
- apiserver
networks:
- frontnet
- backnet
volumes:
- ./shared-files/proxy-nginx.conf:/etc/nginx/nginx.conf
- ./localhost.crt:/etc/nginx/cert.crt # replace with real certificate
- ./localhost.key:/etc/nginx/key.key # replace with real key
restart: on-failure:5

# Web server hosts the static files
webserver:
image: lmsdoubtfire/doubtfire-web:latest
ports:
- 8080:8080
networks:
- backnet
restart: on-failure:5

# API server runs the rails project
apiserver:
image: lmsdoubtfire/apiserver:latest
env_file:
- .env.production
ports:
- 3000:3000
networks:
- backnet
depends_on:
- doubtfire-db
volumes:
- student_work:/student-work # Adjust path to where student data should be stored
- doubtfire_logs:/doubtfire/log
- ./shared-files:/shared-files
- ./shared-files/aliases:/etc/aliases:ro
command: /bin/bash -c "bundle exec rails s -b 0.0.0.0"
restart: on-failure:5

# Database server - could be external to docker
doubtfire-db:
image: mariadb:latest
restart: always
networks:
- backnet
environment:
MARIADB_RANDOM_ROOT_PASSWORD: "true"
MARIADB_USER: dfire # Update with mariadb username
MARIADB_PASSWORD: pwd # Update with mariadb password
MARIADB_DATABASE: doubtfire # Update with mariadb database name
volumes:
- mysql_db:/var/lib/mysql

# Automated generation of PDFs using cron
pdfgen:
image: lmsdoubtfire/appserver:latest
env_file:
- .env.production
networks:
- backnet
depends_on:
- doubtfire-db
volumes:
- student_work:/student-work # Update with path to student work
- ./shared-files:/shared-files
- ./shared-files/aliases:/etc/aliases:ro
- doubtfire_logs:/doubtfire/log
command:
/bin/bash -c "newaliases; cp /shared-files/msmtprc /etc; /doubtfire/entry_point.sh"
restart: on-failure:5

# watchtower keeps all docker containers up to date with latest on dockerhub
watchtower:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock

volumes:
doubtfire_logs: {}
mysql_db: {}
student_work: {}