This service stores Students and is an example of an architecture for a python fastapi micro-service.
cd docker/postgres
docker build --tag motimatic-postgres .
make db # db runs on port 5433 -> 5432 on docker
# from project-root
docker build --tag motimatic-student-base -f base.Dockerfile .
Only needed if you plan on running Snyk locally, right now CI handles Snyk scans
make db # upgrade to the lastest revision
pipenv run alembic upgrade head # Upgrade to the most recent
pipenv run alembic upgrade +1 # Upgrade one migration
pipenv run alembic downgrade -2 # Downgrade two migrations
pipenv run alembic upgrade ae1027a6acf+2 # Upgrade to ae1027a6acf and two addition migrations forward
- Update appropriate models in
app/models
- Run
pipenv run alembic revision --autogenerate -m "migration name here"
- Edit the generated migration file
- NOTE: the generated migration may be missing imports or may have extraneous values added. As a result, the migration may not be executable immediately after generation
- Test migration via
make db
- Run
pipenv run alembic revision -m "migration name here"
- Edit the generated migration file
- Test migration via
pipenv run alembic upgrade head
A Makefile
contains useful commands
make db # start the postgres test database and run migrations
make start # service starts via the shell on port 8001 and auto-reloads
docker-compose down postgres # if you have started postgres with `make db` there will be issues
docker-compose build student-svc # if it hasn't been built
docker-compose up -d student-svc # starts on port 8002, -d is optional to run in demon mode
# service auto-reloads
make test
make fix
make lint
make clean