Skip to content

Setting up HY staging environment

Tapani Honkanen edited this page May 7, 2021 · 2 revisions

How the pipeline works

  1. Developers make changes to the main branch on Github.
  2. Github Actions workflow starts which builds and uploads Docker images to Docker Hub.
  3. Watchtower container running on staging server listens for new Docker images. It will pull the uploaded images when it detects changes and restarts containers.
  4. The changes are now visible on the staging server.

Setting up the pipeline

  1. 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.
  2. Provide DOCKERHUB_USERNAME and DOCKERHUB_TOKEN as Github Secrets here. 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
  3. Ask instructors for permissions to access the staging server.
  4. Login to the staging server according to the instructions you should have been provided with. This includes running a login script.
  5. Create a file docker-compose.yml to /quantmark. Example content can be found here but you need to replace the hard-coded username "tapanih" from image names with your Docker Hub username.
  6. Create a file quantmark.subfolder.conf to /nginx/config/nginx/proxy-confs with the following contents:
location /quantmark {
	proxy_pass http://quantmark-web:8000;
        proxy_set_header Host $host;
}
  1. All done!

Known issues

  • The staging server is very close to the development environment when it should reflect the production environment.
  • The staging server does not serve static files at all. So far this has not been an issue but this might change in the future.
  • The staging server runs in a path /quantmark 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

Repositories

Clone this wiki locally