Production Environment

27-07-2018 (dd-mm-yyyy)

This article aims to document the production environment


All of pydis (short for "python discord") is currently hosted on a single VPS.

Pydis consists of this website, the discord bot, a database, a message queue and a python execution sandbox. Each service is hosted inside a docker container. The deployment of these services is automated using GitLab CI and SaltStack. GitLab CI builds the docker containers when pushing and merging to the master branch. If the build succeeds a http request is sent to the VPS, that tells SaltStack to deploy the new docker container.


  • Docker

  • SaltStack

  • GitLab CI

  • RethinkDB

  • RabbitMQ

  • NSJail


Since everything is running in a docker container, deploying new code changes is as simple as building the docker container, pushing it to and then downloading on to a server.

At pydis we like to automate things as much as possible, so deployment is handled as soon as your pull request gets merged to the master branch.

But how?

GitLab CI is configured in the .gitlab-ci.yml file to test and build the code.

If the job is on the master branch the following events happen (in order):
  1. Install prerequisites

  2. lint check

  3. Unit testing

  4. build docker image

  5. push docker image to

  6. call custom web api to deploy new container

On the server hosting the custom API, the following events occur when it receives the webhook from GitLab:
  1. API triggers salt-event

  2. Salt Reactor triggers state.apply for the given service

  3. state.apply step 1 Downloads the latest images

  4. state.apply step 2 Starts the container with environment variables defined in the state