Tarmo - Tampere Mobilemap
- Install Docker based on your platform's instructions.
- Create a Python virtual environment and activate it.
pip install pip-tools
pip-sync requirements-dev.txt
pre-commit install
Use Node>=v16. See instructions for acquiring an NLS API key (in Finnish). Optionally, see instructions for acquiring a Digitransit API key if you want bus stops on your map.
- Build and start the development containers with
docker-compose -f docker-compose.dev.yml up -d
- Populate the database by running
make test-all-layers
. - Navigate into the
web
directory. - Copy
.env.sample
as.env
and fill your NLS API key (plus optionally Digitransit API key). - Install dependencies:
yarn
- Run the development server in localhost:3000:
yarn run start
- Install also main requirements to the same python virtual environment:
pip-sync requirements.txt requirements-dev.txt
pre-commit install
- Run tests with
make pytest
- Build and start the development containers with
docker-compose -f docker-compose.dev.yml up -d
- Edit the lambda functions and restart the containers with
make rebuild
to see the changes.
If test using pytest-docker get stuck, you can remove the dangling containers with:
docker ps --format '{{.Names}}' |grep pytest | awk '{print $1}' | xargs -I {} docker stop {}
docker ps --format '{{.Names}}' |grep pytest | awk '{print $1}' | xargs -I {} docker rm {}
docker network ls --format {{.Name}} |grep pytest | awk '{print $1}' | xargs -I {} docker network rm {}
- Make sure your backend requirements are installed:
pip-sync requirements.txt requirements-dev.txt
. - Add your changes to the model sql.
- Create a new database revision with
make revision name="describe your changes"
. This creates a new random id (uuid
) for your migration, and two things in the alembic versions dir:- New revision file
uuid_your_message.py
, - New revision sql directory
uuid
.
- New revision file
- Add the needed difference SQL (generated e.g. manually or with pgdiff) as
upgrade.sql
inside the newuuid
directory. - Add a
downgrade.sql
that will cancel theupgrade.sql
operations in the same directory. - Run tests with
make pytest
to check that your new model.sql, upgrade.sql and downgrade.sql run properly. - Run
make rebuild
andmake test-create-db
to start development instance with the new model. - To update the database documentation to reflect the changes, install tbls and run
tbls doc --force
. - Commit
model.sql
, theuuid_your_message.py
file anduuid
directory content, as well as the documentation changes indbdoc
directory, to Github.