- Install python3 virtual environment
python3 -m venv venv
source venv/bin/activate
- create
.env
file
cat > .env << __ENV
JWT_SECRET_KEY=testsecretkey
ENGINE=postgres
POSTGRES_HOST=192.168.10.1
POSTGRES_PORT=5433
POSTGRES_DB=profile
POSTGRES_USER=profile
POSTGRES_PASSWORD=profilesecret
__ENV
- export variables from
.env
file
export $(cat .env | xargs)
- modules
pip install aiohttp aiohttp-jinja2 aiohttp-swagger \
aiopg sqlalchemy marshmallow aiohttp_jwt \
aiohttp_apispec pytest pytest-cov pytest-aiohttp
- run
python3 app.py
- tests
pytest -v --cov=. --cov-report=term-missing
- install docker
- build image
docker build -f Dockerfile -t profile-test ./
- setup
.env
file (p.2) - create docker instance of postgres
docker run -d -p 5433:5432 --name profile-postgres --env-file .env postgres:13.2-alpine
- run docker image as daemon
docker run --rm -d -p 8080:8080 --env-file .env --name profile-api profile-api
- attach to api container and create schema
docker exec -i profile-api python <<-__CODE__
from sqlalchemy import create_engine
from settings import dsn
from models import Base
engine = create_engine(dsn)
Base.metadata.create_all(engine)
__CODE__
* [API](http://localhost:8080/api/v1/doc)
* [API docs](http://localhost:8080/api/doc)