Skip to content
This repository was archived by the owner on Dec 15, 2023. It is now read-only.

wc-guide/wc-guide-backend

Repository files navigation

wc-guide-backend

Overview

Development

Prerequisites

To start development make sure the following applications are installed:

Setup

Database

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

Backend

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.

Testing

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

Examples

Stored Data

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).

Overpass

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).

Ip-Api

There is a ip-api endpoint that forwards the request to Ip-Api that is geolocation Api.

curl http://localhost:8000/ip-api/

Deployment

The wc-guide-backend is running on an instance for Scaleway.

The instance can be reached via ssh (requires certificate):

ssh root@51.15.121.145

Further, on the Scaleway instance is Dokku installed to enable continuous deployment.

Setup

Dokku setup that has to be done as prerequisite.

Dokku Server

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 DJANGO_SUPERUSER_EMAIL=guide@wc-guide.com 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.

Local Machine (GitHub)

To deploy the wc-guide-backend you have to add the remote repository.

git remote add dokku dokku@51.15.121.145:wc-guide-backend

Afterwards you are able to deploy / push your changes to the server.

git push dokku main

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •