-
Notifications
You must be signed in to change notification settings - Fork 0
CI & staging
-
Developers make changes to the main branch on Github.
-
The change in the main-branch triggers a GitHub Action, which results in a Docker image being built and getting pushed to a DockerHub repository.
(On the current staging server:)
-
A Watchtower container running on the staging server keeps track of new Docker images on DockerHub. It will pull the uploaded images when it detects changes and restarts containers, resulting in the updated images being run with minimal delay. The updating should thus work automagically.
-
The changes are now visible on the staging server (see that some changes like changes to the database might need more than just restarting. In other words, manual actions on the server. See Useful and needed docker commands.)
- Create a Docker Hub account and create an access token. An access token can be created by logging in to Docker Hub and clicking on your username in the top right corner and selecting Account Settings > Security > New Access Token.
- Provide DOCKERHUB_USERNAME and DOCKERHUB_TOKEN as Github Secrets. The secrets cannot be read after they have been set so they are safe from your fellow developers!
- DOCKERHUB_USERNAME is your Docker Hub username
- DOCKERHUB_TOKEN is the access token you created
- Ask instructors for permissions to access the staging server.
- Login to the staging server according to the instructions you should have been provided with by the instructors. At the moment of writing, this includes running a login script in the root folder.
- Create a file
docker-compose.yml
in/home/ohtup_user/qleader/
. Here is an example docker-compose.yml based on the current file in the staging. - Create a file
qleader.subfolder.conf
in/home/ohtup_user/nginx/config/nginx/proxy-confs/
like this configuration - Create a .env file with all the OAuth2 secrets and other key information (example .env)
- For how to get the keys and secrets see our Python social auth page
- Create a folder
/home/ohtup_user/qleader/static
which holds the Django and REST Framework static files. Lighttpd in container qleader-static will serve these.
If the data structure changes in the program, but the database itself is left unchanged, the mismatch will result in an error, and the service will not be able to work. At the moment of writing this, our solution for this has been to delete the old database and build a new one (if the program is in production, there would need to be a way to migrate the data from the old db to the new one -- we don't know how to do this yet).
The simplest way to delete the database on the staging server ("ohtup-staging") is to stop and remove the docker container. See the Docker cheat sheet
The staging server runs in a path /qleader
so hard-coded links between pages will not work. For example, this is NOT going to work:
return redirect('/newMolecule/') # WILL NOT WORK ON STAGING!
You should use a view name instead (defined in urls.py) so this is correct:
return redirect('newMolecule') # using view name defined in urls.py
In HTML templates you can use the variable path_prefix:
<a href="{{ path_prefix }}/newMolecule/">New molecule</a>