This is a template repository aimed to kick-start your project with a setup from a real-world application! This template utilizes the following tech stack:
When the Docker is started, these are the URL addresses:
- Backend Application (API docs)
$\rightarrow$ http://localhost:8001/docs - Database editor (Adminer)
$\rightarrow$ http//localhost:8081
This backend application is setup with Docker.
-
Before setting up the backend app, please create a new directory called
coveragefor the testing report purpose:mkdir coverage
-
Backend app setup:
# Creating VENV python -m venv anyname # Install dependencies pip install -r requirements.txt # Test run your backend server uvicorn src.main:backend_app --reload
-
Testing with
PyTest: Make sure that you are in thebackend/directory.# For testing without Docker pytest # For testing within Docker docker exec backend_app pytest
-
Pre-Commitsetup:# Make sure you are in the ROOT project directory pre-commit install pre-commit autoupdate -
Backend app credentials setup: If you are not used to VIM or Linux CLI, then ignore the
echocommand and do it manually. All the secret variables for this template are located in.env.example.If you want to have another name for the secret variables, don't forget to change them also in:
backend/src/config/base.pydocker-compose.yaml
# Make sure you are in the ROOT project directory touch .env echo "SECRET_VARIABLE=SECRET_VARIABLE_VALUE" >> .env
-
CODEOWNERSsetup: Go to.github/and openCODEOWNERSfile. This file is to assign the code to a specific team member so you can distribute the weights of the project clearly. -
Docker setup:
# Make sure you are in the ROOT project directory chmod +x entrypoint.sh docker-compose build docker-compose up # Every time you write a new code, update your container with: docker-compose up -d --build
-
(IMPORTANT) Database setup:
# (Docker) Generate revision for the database auto-migrations docker exec backend_app alembic revision --autogenerate -m "YOUR MIGRATION TITLE" docker exec backend_app alembic upgrade head # to register the database classes # (Local) Generate revision for the database auto-migrations alembic revision --autogenerate -m "YOUR MIGRATION TITLE" alembic upgrade head # to register the database classes
-
Go to https://about.codecov.io/, and sign up with your github to get the
CODECOV_TOKEN -
Go to your GitHub and register all the secret variables (look in .env.example) in your repository (
settings$\rightarrow$ (scroll down a bit)Secrets$\rightarrow$ Actions$\rightarrow$ New repository secret)
IMPORTANT: Without the secrets registered in Codecov and GitHub, your CI will fail and life will be horrible 🤮🤬
IMPORTANT: Remember to always run the container update every once in a while. Without the arguments -d --build, your Docker dashboard will be full of junk containers!