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.
Since everything is running in a docker container, deploying new code changes is as simple as building the docker container, pushing it to docker.io 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.
GitLab CI is configured in the .gitlab-ci.yml file to test and build the code.
build docker image
push docker image to docker.io
call custom web api to deploy new container
API triggers salt-event
Salt Reactor triggers
state.apply for the given service
state.apply step 1 Downloads the latest images
state.apply step 2 Starts the container with environment variables defined in the state