Deploying containers
Instructions on using the Xirrix-siteserver in a docker container.
We will be switching to this way of managing Siteservers and deploying them. There is some prequsites, that you must have to use this.
- You will need Docker,
- Docker compose,
- a github PAT (personal access token) and
- knowledge of how they work.
- A siteserver config.yml
Im going to assume you have docker/docker compose already installed.
Getting the Github PAT.
First you should check with the team, to see if there is an active one you can have, if noone has an active one you will need to make a new one.
Make sure to keep the PAT very safe, as it can be used to access all of the Github repositories.
- Go to Itsupport GitHub account settings.
- Click on "Developer settings" → "Personal access tokens" → "Generate new token".
- Grant the token the necessary scopes - write:packages, read:packages.
- Save the generated token securely.
Logging into the github container registry.
On the server that will be running the containers we must loginto the GHCR (Github container registry), that is where we are storing the created github containers.
In the home directory of your user, you should make a 'docker' folder, mkdir docker, inside this folder you should make a file called PAT and paste the pat in the file with nothing else nano pat.
From this folder run the following command. Make sure to put your github username in the command.
cat pat | docker login ghcr.io -u <Github_Username> --password-stdin
You should receive a message saying login succefull.
Checking the image tags.
You will need to check that you are going to download the correct version of the Sitserver.
Goto this page: https://github.com/users/altogit/packages/container/package/cmdocker
Make sure you are logged in. You can look through the packages to see the different versions, you will use these tags in the docker-compose.yml to pick the version you want to install.
You will need 2, a database container tag (denoted by mysql in the tag name) and a siteserver tag.
Docker-compose.yml
In the CMDOCKER github repo you will find a docker-compose.yml.
This has the basic layout that you will need to spin up a site server. You will need to change the image: section to have the correct tags for the versions you want to run.
You should also check that the bind mount for the config.yml file is point to the file on your local system, by default it looks for it in the current directory.
Starting the containers.
For testing you should start the containers with this command.
docker compose up --force-recreate
For production use you should use this command.
docker compose up -d --force-recreate
The containers should start to deploy, the siteserver will not start until the database comes online as 'healthy' as specified in the compose file.
Checking the siteserver logs.
Checking the siteserver logs can be done 2 ways.
Entering the docker container and navigating the files.
You can enter the container by running this command.
docker exec -it <CONTAINER_NAME> /bin/bash
Then you may traverse the workspace as normal, this is usefull for checking that files are in the correct spot etc.
You can also directly tails the logs with this commnnad.
docker exec -it <CONTAINER_NAME> tail -fn 500 /workspace/siteserver.log
Make sure that you change <CONTAINER_NAME> to be the name of the container as specified by container_name: in the compose yml or by running docker ps -a to list running containers and to use the hex code containerId.