-
Docker Compose (already packaged in Docker Desktop)
-
Environment variables:
Environment Variable Description Required Recommended Value POSTGRES_DBName of the Postgres database. Should be lowercase Yes turmfrontendPOSTGRES_USERSuperuser of the Postgres Database Yes adminPOSTGRES_PASSWORDSuperuser password Yes Secure password DEBUGWhether Django runs the server in DEBUG mode (default: False) No Truefor development,Falsefor deploymentADMIN_EMAILEmail of the admin user that is logged in by default when DEBUGis set toTrueYes admin@admin.comADMIN_PASSWORDPassword of the admin user that is assigned in by default when DEBUGis set toTrueYes adminDB_VOLUMELocation of DB Volume. If left empty the data will only be saved in the docker volume and will not be mapped to a local folder (increases first startup time) No ./data/dbfor mapping to local folderDB_PORTLocal Port that the Postgres DB can be accessed on (outside the container) Yes 5432WEB_PORTLocal Port used for the website Yes 8000NC_PORTLocal Port that the Nextcloud can be accessed on No 8080, only required for Nextcloud testingNC_USERUser for the Nextcloud instance No Nextcloud User NC_PASSWORDPassword for the Nextcloud instance No Nextcloud password NC_URLURL to the Nextcloud instance Yes http://localhost:8080, when testing locally.http://turmfrontend-nextcloud:80when run in DockerNC_PREFIXTop level folders in the nextcloud to store the observations in . Entered as string (without "" or leading/following '/' for multiple folders) No test, default/non-existing: root directory of nextcloud,NC_TESTThe nextcloud test cannot run in CI. If set to false these test are skipped No default/non-existing TrueSUBPATHSubpath the website is being deployed on No. /tom SECRET_KEYSecret Django Key. Keep private and wrap in " to prevent formatting on # or $. You might have to escape $ with \ No See https://djecrety.ir/. Always set a private key for deployment! BASE_URLBase Website URL Yes http://localhost:8000 CONFIG_PATHPath to the config file, relative to the root directory Yes ./default_config.json
The easiest way is to create a local .env file in the root directory of the project with the following content:
POSTGRES_DB=TURMFrontend
POSTGRES_USER=<user>
POSTGRES_PASSWORD=<password>
DB_VOLUME=./data/db
DEBUG=True
ADMIN_EMAIL=<email>
ADMIN_PASSWORD=<password>
DB_PORT=5432
WEB_PORT=8000
NC_PORT=8080
NC_USER=<user>
NC_PASSWORD=<password>
NC_URL=http://localhost:8080
SECRET_KEY="django-insecure-k\$b\$^f\#%axr_@sur%@5u9ru2sau\$xddv7%wb@kr(vp^y5ad!vu"
BASE_URL="https://localhost:8000"
CONFIG_PATH="./default_config.json"Configure the environment variables in the .env file as described above.
Additionally, you can configure a copy of the default_config.json file in the root directory of the project and link it in the .env.
If you encounter turmfrontend-web | manage.py load_configuration: error: the following arguments are required: path , the CONFIG_PATH variable is not set correctly.
To develop the project locally, install the dependencies running both
pip install -r requirements.txt and pip install -r requirements_dev.txt.
Prettier is used to format JS and CSS files, you can install it here
Run the server using docker-compose up.
Our CI enforces properly formatted code. To format the code, run scripts/format.sh.
Alternatively, you can comment /format on any pull request to automatically run the formatting script and commit the changes.
To run the tests, run python manage.py test or docker exec turmfrontend-web python manage.py test to run the tests inside Docker.
Once you run the app you will be prompted to login.
If you set both the ADMIN_EMAIL and the ADMIN_PASSWORD environment variable,
a admin user will be created with the given credentials, which can be used to login.
Run using docker-compose up in the root directory of the project. The application will be available at http://localhost:8000.
Hot reloading is supported. The data will be saved in a PostgreSQL database, inside the data folder.
Optionally use docker-compose --profile test up to run a (non-persisting) Nextcloud Container useful for testing.
- The Nextcloud container is not persistent. This is by design, as the Nextcloud container is only used for testing purposes.
- The test that interact with the nextcloud will automatically add
testto theNC_PREFIXdefined in .env - When changing the nextcloud prefix while files are uploaded in the nextcloud, the update fails as the prefix is not stored with the observation in the database.
- During development some migration files might have been deleted. This means that the database might need to be reset when running the application for the first time. If the database was used without mapping the volume to a local folder, simply run
docker-compose down -vto remove all docker volumes. If the volume was mapped to a local folder, simply delete the folder and rundocker-compose upagain. - Dependencies are only installed when building the Docker image. If a new dependency is added, you can rebuild the image using
docker-compose up --buildor installrequirements.txtusingdocker exec turmfrontend-web pip install -r requirements.txt.