- Python 3.8+ and pip
- NodeJS 18+ and npm
- MongoDB server
cd ./backend
pip3 install -r requirements.txt
Insert the link to the main.py
file:
MongoClient("Link (Connection String) to your MongoDB")
uvicorn main:app
From base folder:
cd ./frontend
npm install
npm start
{
"name": "Python: FastAPI",
"type": "python",
"request": "launch",
"module": "uvicorn",
"cwd": "${workspaceFolder}/backend",
"envFile": "${workspaceFolder}/backend/.env",
"args": [
"main:app"
],
"jinja": true,
"justMyCode": true
}
To deploy the application, follow these steps:
curl -fsSL get.docker.com | bash
curl -SL https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
Create a copy of the .env.example file and name it .env. Open the .env file and modify the values to match your configuration.
Build all Docker containers by running the command:
docker-compose build
# If you need to debug, you can run
docker-compose build --progress plain --no-cache backend
# to upload image to docker.hub.io
docker login
# lets upload
docker-compose push
Start all Docker containers with the following command:
docker-compose up
# Alternatively, for better output:
docker-compose up -d && docker-compose ps && docker-compose logs -f
To view a list of all volumes on your Docker daemon, use the command:
docker volume ls
# If needed, you can remove a specific volume by running:
docker volume rm <VOLUME_NAME>
If you require a self-signed certificate, generate it using the following commands:
openssl genpkey -algorithm RSA -out private.key -pkeyopt rsa_keygen_bits:2048
openssl req -new -x509 -key private.key -out certificate.crt -days 365
That's it! Your application should now be deployed and running using Docker.