WIP: very basic template, don't use yet, WIP.
- Python >= 3.11
- Poetry >= 2.0.0 (Optinal recommended)
- Docker (optional)
- Google Cloud credentials and environment variables
- Access to Polilan repository
it depends on poetry and docker, you need to install them.
### I'm specting to handle everything in one command, WIP
make start
# Create virtual environment
python3 -m venv .venv
# Activate virtual environment
# For Unix/MacOS:
source .venv/bin/activate
# For Windows:
.venv\Scripts\activate
# Install required packages
pip install -r requirements.txt
You'll need to obtain the following from the Polilan dev team:
- Google Cloud credential file (place in
/.cred
folder) - Environment variables template (
.env
file)
uvicorn app.main:app --reload
# Optionally, if you want to use fastapi dev
fastapi dev app/main.py
Once running, access the API documentation at: http://127.0.0.1:8000/docs
Environment | URL |
---|---|
QA | https://..... |
Production | https://..... |
add .env file to the root of the project
make gcp-build
make gcp-deploy
Note: before try to automate the deployment, i highly recommend do one manual deployment to check if everything is working. specially becouse for every cloud run service, variables need to be set first time, consecutives times no need. also check first deployment is in gcr default repository for artifact, but for automated is in custom repository
- Fork the repository
- Go to cloud build and create a new trigger
- Grant github access, select the repository and accept conditions
- Add seetings for the trigger to your needs
- Optional: Add permissions to the service account, Logs Writer, Cloud Run Admin or log only default logs
- Add the repository in artifact registry (recommended add policies to remove old versions)
poetry add
poetry add poetry remove poetry update poetry install poetry build poetry publish poetry show : check dependencies
docker build -t dc_python_server_image .
docker run -it -p 8080:8080 dc_python_server_image