2022-04-20 12:42:51 -06:00
# User Acceptance Testing (UAT) environment
2022-04-13 09:29:55 -06:00
2022-04-20 12:49:30 -06:00
Hostname: `api.uat.retropilot.org`
2022-04-14 08:51:13 -06:00
2022-04-20 12:23:27 -06:00
## Setup
2022-04-14 08:51:13 -06:00
2022-04-20 12:23:27 -06:00
This setup assumes you have `docker` and `docker-compose` installed on your machine, and that you have added the
2022-04-20 12:42:51 -06:00
relevant users to the `docker` group. Instructions given below are an example - you should look to the official
documentation [here for Docker Engine ](https://docs.docker.com/engine/install/ ) and [here for Docker Compose ](https://docs.docker.com/compose/install/ ).
2022-04-14 08:51:13 -06:00
2022-04-20 12:23:27 -06:00
```sh
# install docker and setup systemd to start it on boot
sudo yum install docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo systemctl enable docker
2022-04-14 08:51:13 -06:00
2022-04-20 12:23:27 -06:00
# add $USER to the docker group
sudo usermod -aG docker $USER
2022-04-20 12:42:51 -06:00
# logout and back in to see the change
# install docker compose v2 for all users
DOCKER_CONFIG=/usr/local/lib/docker
sudo mkdir -p $DOCKER_CONFIG/cli-plugins
sudo curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
sudo chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
# test docker compose
docker compose version
2022-04-14 08:51:13 -06:00
```
2022-04-20 12:23:27 -06:00
Clone the Git repo to `/data/retropilot-server` . We can clone it using the `--shared` argument to allow multiple users
to read/write these files (taking advantage of the Linux `sgid` permissions bit).
```sh
# create /data directory and relax permissions to let a non-root user write to it
sudo mkdir /data
sudo chmod a+w /data
# clone the repository
cd /data
git clone https://github.com/RetroPilot/retropilot-server.git --shared --branch uat
# allow any user in the 'docker' group to read/write the files in this directory
sudo chgrp -R docker retropilot-server
# tighten /data permissions again so that not non-root users cannot write to it
sudo chmod a-w /data
2022-04-14 08:51:13 -06:00
```
2022-04-20 12:23:27 -06:00
## Deployment
Make sure to create and modify the `.env` file as required for your environment.
2022-04-14 08:51:13 -06:00
Note that the first time you run the PostgreSQL container it will have to initialise.
The server and worker cannot interact with it before this happens.
2022-04-20 12:23:27 -06:00
Before first run (in `/data/retropilot-server` ):
```sh
2022-04-14 08:51:13 -06:00
cd environment/uat
2022-04-20 12:23:27 -06:00
# copy and modify the `.env` file as required
cp .env.sample .env
# create the database
2022-04-20 12:42:51 -06:00
docker compose up db
2022-04-14 08:51:13 -06:00
# CTRL-C when "database system is ready to accept connections" message appears
2022-04-20 12:23:27 -06:00
# allow the API to initialise the database schema
2022-04-20 12:42:51 -06:00
docker compose up db api
2022-04-14 08:51:13 -06:00
# CTRL-C when "RetroPilot Server listening at" message appears
```
To start all the services:
2022-04-20 12:42:51 -06:00
```sh
2022-04-14 08:51:13 -06:00
cd environment/uat
2022-04-20 12:42:51 -06:00
docker compose up -d
2022-04-14 08:51:13 -06:00
```