I had a great time making this app over the course of a few weeks. To build on my experience from the App Academy bootcamp, I really tried to expand on my "infrastructure as code" skills by utilizing multistage Docker builds, layered caching, and Github Actions to build a simple CI/CD pipeline. It was immensely satisfying glueing the pieces of it together with the Python skills I've been developing over the prior few months and to see it become a more robust, maintainable project complete with ๐ฏ percent test coverage! (not a great metric, I know, but it was still fun to chase!)
I have prepared a docker-compose file, so after cloning, you should only need to setup a few environment variables. The Pydantic Settings schema in app.config provides valid defaults for all of these, so it should run regardless, but the required environment variables in a .env file are:
APP_NAME="asana_fastapi"
DB_URL="sqlite:///app.db"
SECRET_KEY="dummykey"
ALGORITHM="HS256" # password hashing algorithm
ACCESS_TOKEN_EXPIRES_MINUTES=30 # auth token expiration
The project is setup with some SQLite defaults, but if planning to use PostgreSQL, the docker-compose requires the following in a .env.db file:
POSTGRES_USER="db_username"
POSTGRES_PASSWORD="db_password"
POSTGRES_DB="db_user"
Alternatively, you can just pull and run the dev or prod image from the GitHub Container Registry for this project by using one of these commands with the Docker CLI installed. After failing to find the image locally, Docker will look to the GitHub Container Registry for the image automatically.
docker run --name asana_fastapi -p 8000:80 -d --rm ghcr.io/colerutledge/asana_fastapi:dev
docker run --name asana_fastapi -p 8000:80 -d --rm ghcr.io/colerutledge/asana_fastapi:prod
You can reach the interactive API docs powered by Swagger/OpenAPI here: http://localhost:8000/docs
Alternative docs powered by ReDoc can be found here: http://localhost:8000/redoc
Link to live API Docs powered by OpenAPI
you may have to give Heroku a minute!