A vanilla Django application with docker-compose to enable developers to quickly get a skeleton site running on GOOGLE compute engine. Either user the included otis Django project to start with, or just use the docker insfrastructure and container inits to quickly create a platform to build your own Django project into.
- https://console.cloud.google.com/compute/instancesAdd
- Name the instance
- Select region
- Select machine type ( I choose e2-small (2 vCPU, 2 GB memory)
- Under firewall tick allow HTTP traffic and allow HTTPS traffic
- Click create
- Create a personal access token for GIT - https://github.com/settings/tokens, setting full repo permissions
- Install wget: sudo apt-get install wget
- Download code to server running following command:
wget -d --header="Authorization: token " https://github.com/nmcilree/otis/archive/main.zip
- Install zip by running: sudo apt-get install zip
- Run unzip main.zip
- Update ALLOWED_HOSTS in otis-main/app/otis/settings.py to the URLs you which to allow to access the site.
- Install Docker on the compute engine https://docs.docker.com/engine/install/debian/, run “dpkg --print-architecture” if you need to check what processor your server has
- Install docker compose https://docs.docker.com/compose/install/
- (optional) Install tmux:
- sudo apt-get install tmux
- Install snapd - https://snapcraft.io/docs/installing-snap-on-debian
- Install certbot from lets encrypt - https://certbot.eff.org/lets-encrypt/debianstretch-other
- If not done in part 3 run certbot in standalone mode: sudo certbot certonly --standalone. This should output a message with the location of your generated certificates.
- Copy the fullchain and privkey to the nginx/container folder
- Change ownership from root to current user - sudo chown -R <user> ./*
- Uncomment lines at bottom of otis-main/containers/nginx/Dockerfile relating to location of SSL certificates (or amend to where your certificates are stored)
- Update container otis-main/nginx/nginx.conf with your sites domain name ( replace otis.site.com )
- CD to the otis-main folder
- sudo docker-compose build
- Run containers - sudo docker-compose up ( you might need to up them separately ( hence tmux ) as the postgres container would often take longer to initialise than the django one )
- Remote into otis_django container to run initial migrations - “docker exec -it otis_django bash”
- Run python manage.py migrate
- Run python manage.py collectstatic
You should now be able to access your site