A back end web application about reference letter handling in the context of DIT HUA Thesis "Use of devops methodologies and tools in development and production environment of web applications"
- Table Of Contents
- Run Project Locally (Installation)
2.1 Clone and initialize project
2.2 Run application server - Deploy fastapi project to a VM (Virtual Machine)
3.1. CI/CD tool configuration (Jenkins Server)
3.2. Deployment with Docker and docker-compose using Ansible
git clone https://github.com/panagiotis-bellias-it21871/reference-letters-fastapi-server.git
virtualenv fvenv -p python3.X
source fvenv/bin/activate
pip install -r requirements.txt
and
cp ref_letters/.env.example ref_letters/.env
editting .env file to define
DATABASE_URL=sqlite:///./dev.db
ORIGINS = "http://127.0.0.1:8000" # client's ip and port
KC_SERVER_URL="https://auth.some-domain.com/auth"
KC_CLIENT_ID="test-client"
KC_REALM="Test"
KC_CLIENT_SECRET="GzgACcJzhzQ4j8kWhmhazt7WSdxDVUyE"
or
cp ref_letters/.env.docker.example ref_letters/.env
DATABASE_URL=postgresql://<DB-USERNAME>:<DB-PASSWORD>@localhost:5432/<DB-NAME>
ORIGINS = "http://vuejs/" # client's ip and port
KC_SERVER_URL="http://keycloak_auth:8085/auth/"
KC_CLIENT_ID="fastapi-service"
KC_REALM="Clients"
KC_CLIENT_SECRET="GzgACcJzhzQ4j8kWhmhazt7WSdxDVUyE"
in case you want to use postgresql either you are in a docker environment or not. First you should have created a database using pgAdmin or command line. The other variables are referred in keycloak usage where you should suit them according to the environment where keycloak service is running.
uvicorn ref_letters.main:app --reload
For deployment see here
For jenkins configuration see here
The fastapi container is built according to the nonroot.Dockerfile as a nonroot process for safety reasons.
More about deployment with Docker see here and here
# build image
docker build . -t ghcr.io/panagiotis-bellias-it21871/ref-letters-fastapi-server:latest -f nonroot.Dockerfile
# push image
docker push ghcr.io/panagiotis-bellias-it21871/ref-letters-fastapi-server:latest