From c6078f4c4607fadf86fdfcbb233c827f27f97e11 Mon Sep 17 00:00:00 2001 From: Bryon Lewis Date: Wed, 21 Feb 2024 08:28:23 -0500 Subject: [PATCH] deployment docs update --- DEPLOYMENT.md | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 1e9ce8c..578bb83 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -27,17 +27,55 @@ for accessing the server. 3. Run `docker compose run --rm django ./manage.py makeclient \ --username your.super.user@email.address \ --uri https://batdetectai.kitware.com/` -4. Run `docker compose run --rm django ./manage.py collectstatic` +4. Run `docker compose run --rm django ./manage.py loaddata species` to load species + data into the database +5. Run `docker compose run --rm django ./manage.py collectstatic` to collect the static files -5. Run `docker compose -f docker-compose.prod.yml up` to start the server +6. Run `docker compose -f docker-compose.prod.yml up` to start the server add `-d` for a silent version to run in the background -6. Copy over the ./dev/.env.prod.docker-compose.template +7. Copy over the ./dev/.env.prod.docker-compose.template to `./dev/.env.prod.docker-compose.template` and change the default passwords -7. Change the ID in the `./client/env.production` to a custom ID -8. After creating the basic application log into the django admin `batdetectai.kitware.com/admin` +8. Change the ID in the `./client/env.production` to a custom ID - this will + probably require a `docker compose build` to build the app afterwards +9. After creating the basic application log into the django admin `batdetectai.kitware.com/admin` and change the ApplicationId to the ID in the `./client.env.production` -9. Test logging in/out and uploading data to the server. +10. Test logging in/out and uploading data to the server. ### system.d service Service that will automatically start and launch the server +Create this at `/etc/systemd/system` using sudo + +```systemd +[Unit] +Description=batai-server +Requires=docker.service +After=docker.service + +[Service] +ExecStartPre=/bin/sleep 10 +Environment=PATH=/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin +Restart=always +User=bryon +Group=docker +TimeoutStartSec=300 +RestartSec=20 +WorkingDirectory=/home/bryon/batai +# Shutdown container (if running) when unit is started +ExecStartPre=docker compose down +# Start container when unit is started +ExecStart=docker compose -f docker-compose.prod.yml up +# Stop container when unit is stopped +ExecStop=docker compose down + +[Install] +WantedBy=multi-user.target +``` + +After run `sudo systemctl enable batai.service` +Then to start you can use `sudo systemctl start batai.service` +Stopping: `sudo systemctl stop batai.service` + +# User Management + +There is no email server connected up so users need to be individually approved and their email verified by an admin