To start development make sure the following applications are installed:
- Docker (https://docs.docker.com/get-docker/)
- Poetry (https://python-poetry.org/docs/)
- GDAL (https://gdal.org/)
Run PostgreSQL Database with PostGIS extension.
docker run --name wc-guide-backend-db -e POSTGRES_DB=wc-guide-backend-db -e POSTGRES_USER=guide -e POSTGRES_PASSWORD=wc-guide-backend -d -p 5432:5432 mdillon/postgis
Run Django Backend.
poetry install
poetry run python manage.py migrate
poetry run python manage.py runserver
Now you can navigate to http://localhost:8000/swagger/ to get the API documentation.
To run the test locally execute the following command:
poetry run pytest -v -s
Further, there is a GitHub Action that executes the tests on over push to main and pull request. GitHub Action Testing
If you want to query all toilets within a certain bounding box, you can do the following request:
curl http://localhost:8000/toilets/?in_bbox=9.283283,47.081593,9.372739,47.133249
The in_box
has to be ordered as follows min Lon (west), min Lat (south), max Lon (east) and max Lat (north).
If you want to query all toilets within a certain bounding box, you can do the following request:
curl http://localhost:8000/overpass/?in_bbox=9.283283,47.081593,9.372739,47.133249
The in_box
has to be ordered as follows min Lon (west), min Lat (south), max Lon (east) and max Lat (north).
There is a ip-api endpoint that forwards the request to Ip-Api that is geolocation Api.
curl http://localhost:8000/ip-api/
The wc-guide-backend is running on an instance for Scaleway.
The instance can be reached via ssh (requires certificate):
Further, on the Scaleway instance is Dokku installed to enable continuous deployment.
Dokku setup that has to be done as prerequisite.
PostgreSQL Database:
docker run --name wc-guide-backend-db -e POSTGRES_DB=wc-guide-backend-db -e POSTGRES_USER=guide -e POSTGRES_PASSWORD=wc-guide-backend -d -p 5432:5432 mdillon/postgis
wc-guide-backend:
dokku apps:create wc-guide-backend
dokku nginx:set wc-guide-backend client-max-body-size 128m # Did not work had to be set manualy
dokku config:set wc-guide-backend DJANGO_DEBUG=False DJANGO_SECRET_KEY=Pcp2FV9Ad1dbFSNhJXFAGZ2tsH0vCpQCnPLfFXVRq04bL0y05VrzrbfPxV9nl5gSEJmzIkelMye0PIvlR6TKk9GdavARmj0YTqGP
dokku config:set wc-guide-backend DJANGO_SUPERUSER_USERNAME=guide [email protected] DJANGO_SUPERUSER_PASSWORD=8q6mDmQH5uxH
As you can see we set env variables for the superuser, they are used within the Dockerfile to create the superuser. Further, the intention is to use the superuser to create/updated data.
To deploy the wc-guide-backend you have to add the remote repository.
git remote add dokku [email protected]:wc-guide-backend
Afterwards you are able to deploy / push your changes to the server.
git push dokku main