This repository holds the necessary configuration files for performing a full production deployment of the Trade Wars stack. This includes the gamemode and all additional services that it depends on.
Deployment uses Docker Compose and also makes use of Watchtower for automatic restarts when new versions of dependencies are available. In future, this will be modified or built upon to provide a graceful restart cycle that ensures players and operators are notified of an incoming restart and given a grace period as well as a way to cancel a restart.
Services must use the following three primary branches to be compatible with this deployment setup:
master
represents the stable, public, live version - the code running here must have gone through testing with other components indevelop
as well as a staging release onstaging
.staging
represents the next stable version - the version running here will eventually run in production providing no last-minute issues are discovered.develop
is a rolling release for testing new features and merging feature branches for integration testing.
Simply by pushing to those branches will trigger the Watchtower application running on the deployment server to automatically update the running images once it sees new ones hit the Docker Hub.
To perform a deployment, you must clone this repository to your local machine
and cd
into it. Once you've done that, proceed with the deployment commands
detailed below.
First, you must declare whether you are deploying to a development environment or a production environment.
Environments are defined in "env-files". The environment that will be used by
the deployment is stored in the file named .env
. This doesn't exist on the
repository because it may contain sensitive information. Deployment is split
between environments by storing configuration variables in a .env
file either
called dev.env
or prod.env
which is then copied to a "live file" named
simply .env
which is used by the docker-compose
command. The dev.env
file
is included in this repository because it contains simple database credentials.
If you are deploying a development environment, you already have the dev.env
file so all you need to do is run the following command that will simply copy
dev.env
to the live file .env
:
make dev
But if you are deploying to production, you must first manually create the file
prod.env
which must contain all necessary environment variables. Copy the
dev.env
file and change each variable appropriately:
- ALWAYS generate long, strong, complex passwords
- NEVER re-use passwords across deployments
- ALWAYS store passwords in a safe location
- NEVER commit sensitive credentials to source control
Once you've done that, run the following command to set the live .env
file to
the production settings:
make prod
Once the environment has been set up and .env
contains your target variables,
you can deploy the entire stack with:
make up
This simply runs docker-compose up
with any necessary options.