-
Notifications
You must be signed in to change notification settings - Fork 3
Setup (Docker)
Docker is recommended to run Tracker, as a Docker Compose file and corresponding Dockerfiles are already built to make the process as easy as possible. Certbot-based Let's Encrypt automatic SSL renewal support is provided out-of-the-box with the default production Compose file.
- Clone this repository whereever you will be building/running the Docker containers
- Copy all of the
*.env.example
files in.docker/
to just*.env
(in the same directory)..docker/
should haveapp.env
,certbot.env
,nginx.env
,postgres.env
, andredis.env
. - Modify the
.env
files in.docker/
for your configuration. Specifically, you should ensure the following keys are updated at the very least:-
app.env:
APP_KEY
,APP_URL
,DB_PASSWORD
,REDIS_PASSWORD
,CONCAT_CLIENT_ID
,CONCAT_CLIENT_SECRET
,TELEGRAM_BOT_TOKEN
(see details in the development section for the ConCat and Telegram config keys, as well as for generating a key forAPP_KEY
the first time) -
certbot.env:
LETSENCRYPT_DOMAIN
,LETSENCRYPT_EMAIL
,LETSENCRYPT_DRY_RUN
(clear the value for this once confirmed working) -
nginx.env:
NGINX_HOST
-
postgres.env:
POSTGRES_PASSWORD
(should matchDB_PASSWORD
inapp.env
) -
redis.env:
REDIS_PASSWORD
(should matchREDIS_PASSWORD
inapp.env
)
-
app.env:
- Run
docker compose -f docker-compose.prod.yml build
to build the necessary (app and nginx) images - Run
docker compose -f docker-compose.prod.yml up -d
to run the images in the Docker daemon - Once everything has started up, the application will not yet be functional if it's the first time running.
Follow these steps once the containers are up:
- Run
docker compose -f docker-compose.prod.yml exec app php artisan migrate
to run migrations on the database - Wait for output from certbot in
docker compose -f docker-compose.prod.yml logs certbot
to confirm that the dry-run succeeded - Clear the value for
CERTBOT_DRY_RUN
in certbot.env - Run
docker compose -f docker-compose.prod.yml restart certbot
- Log in to Tracker to make sure a user is created for you
- Run
docker compose -f docker-compose.prod.yml exec app php artisan auth:set-role
to set your user's role to admin
- Run
A convenient update script is provided at /.docker/scripts/update.sh. In this order, that script does the following:
- Pulls the latest changes from the repository (
git pull
) - Builds the updated image (
docker compose -f docker-compose.prod.yml build
) - Restarts the containers with the updated image (
docker compose -f docker-compose.prod.yml down && docker compose -f docker-compose.prod.yml up -d
) - Ensures the log volume's file permissions remain consistent (
docker compose -f docker-compose.prod.yml exec app chown -R www-data:www-data /var/www/html/storage
) - Enables Laravel's maintenance mode (
docker compose -f docker-compose.prod.yml exec app php artisan down
) - Runs any new database migrations (
docker compose -f docker-compose.prod.yml exec app php artisan migrate
) - Disables Laravel's maintenace mode (
docker compose -f docker-compose.prod.yml exec app php artisan up
)
These steps can be completed manually if preferred or if any tweaking is desired.
Whenever the Postgres major version is updated in the Compose file, Postgres needs to be manually upgraded beforehand. If not done, an error like this will likely be encountered at the startup of the Postgres container:
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 15, which is not compatible with this version 16.1 (Debian 16.1-1.pgdg120+1).
Reverting the project (or at least the Compose file) to the previous version should allow the server to start again. Follow this procedure to properly upgrade the database (starting with the server running the old version):
- Run
./docker/scripts/postgres-dump.sh
to dump the contents of the database topgdump.sql
in the project directory - Stop the Postgres container (
docker compose -f docker-compose.prod.yml stop postgres
) - Find the correct volume for the Postgres container in
docker volume ls
- it should be something likeprojectname_postgres
- Delete the volume of the Postgres container (
docker volume rm postgres_volume_name
) - Start the Postgres container (
docker compose -f docker-compose.prod.yml start postgres
) - Run
./docker/scripts/postgres-restore.sh
to importpgdump.sql
into the new Postgres version - Verify that the application is running properly and all of the correct data is in place