locstorager is a microservice that has endpoints to store locations with name, latitude and longitude in a SQL database. The purpose is to store these locations so that later the wrapper-piper service with two ids can make a distance calculation using the Euclidean formula.
For every location saved, we need to return the location id property
- Python 3.11
- Docker
- Postgres
.
├── config.py
├── Dockerfile
├── envrc.example
├── README.md
├── requirements.txt
├── run.py
└── src
├── database
│ ├── db_interface.py
│ ├── __init__.py
│ ├── postgres.py
│ └── schema.py
├── __init__.py
└── locations
├── cache
│ ├── cache_redis.py
│ └── __init__.py
├── data
│ ├── __init__.py
│ ├── pg_access_interface.py
│ └── pg_data_access.py
├── hooks.py
├── __init__.py
├── locs.py
├── models
│ ├── __init__.py
│ └── model.py
└── routes.py
- Clone the repo
https://github.com/Edmartt/locstorager.git
- Browse into the project folder
cd locstorager/
- Create virtual environment
python3 -m venv <virtual environment name>
- Activate virtual environment
source env/bin/activate
- Install dependencies
pip3 install -r requirements
- set the environment variables following the envrc.example
source .envrc
- Run
flask run -p <port>
- Pull the image from Dockerhub
docker pull edmartt/locstorager
-
set .env file following env.example
-
Create container
docker run --rm -p <host-port:docker-port> --env-file .env edmartt/locstorager
This service requires a postgres database, and a redis instance running, so, if we send some requests for saving data in the database we'll get an error. If we try to get all the locations we'll see an erro related to REDIS, this is normal because this service is intended to be attached with docker compose in this project wrapper-piper. You'll find the endpoint docs and the deployment with docker compose in that repo.