Find all the States in the contiguous USA on a map. Simple enough.
- Live URL
- Frontend UI GitHub - Built with TypeScript and React
- Backend API GitHub - Built with Python and FastAPI
# If your running this for the first time, make sure to run the migrations
# Start
docker-compose up -d --build
# Stop
docker-compose down
# Docker cleanup commands https://gist.github.com/johndatserakis/0002d9aded5778f9d0589a23ce1e08d4
# Below are commands to be run when the containers are running locally with docker-comose
# Run migrations
docker-compose exec api poetry run alembic upgrade head
# Run tests
docker-compose exec api pytest .
# Run a specific script
docker-compose exec api python ./program_scripts/get_state_data.py
# Add a dependency
docker-compose exec api poetry add slowapi
# Create poetry.lock file
docker-compose exec api poetry lock
# Create migration (called a "revision")
docker-compose exec api poetry run alembic revision -m "Create score table"
# Run migrations
docker-compose exec api poetry run alembic upgrade head
# Downgrade 1 migration file
docker-compose exec api poetry run alembic downgrade -1
# View list of migration files
docker-compose exec api poetry run alembic history
docker-compose exec api poetry run alembic downgrade $Id
In development I use docker-compose
because it sets up the PostgreSQL
dependency nicely. For the production build, I just use a regular Dockerfile, ./app/Dockerfile-production
, to build the API.
# Currently I'm using AWS ECR for the registry
# From root, build for production using `./app/Dockerfile-production` Dockerfile
docker build \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
-f ./app/Dockerfile-production ./app \
--build-arg POSTGRES_USER=$POSTGRES_USER \
--build-arg POSTGRES_PASSWORD=$POSTGRES_PASSWORD \
--build-arg POSTGRES_HOST=$POSTGRES_HOST \
--build-arg POSTGRES_DB=$POSTGRES_DB
# Run what you built locally to test
docker run -dit --publish 8000:8000 --restart unless-stopped $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# Lastly push to your container registry of choice
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- Python 3.8
- FastAPI
- SQLAlchemy
- Alembic
- pymediawiki
- Poetry
- PostgreSQL
- slowapi
- Below are some links I saved while learning Python.