This guide walks you through setting up and running the NTUAflix application using Docker and docker-compose, including a FastAPI backend, MariaDB database, and Nginx as a reverse proxy.
Team Members: Kokoromytis Georgios, Tsouknida Vasiliki, Jani Spyridon, Panou Konstantina, Papanikolaou Ariadni
- Docker installed on your machine.
- Docker Compose installed on your machine.
-
Clone the Repository
Firstly, clone this repository to your local machine using:
git clone https://github.com/geokoko/Ntuaflix.git
-
Environment Variables
Create a
.env
file in the root directory of the project. This file should contain the necessary environment variables:DB_HOST=db DB_NAME=mydatabase DB_USER=myuser DB_PASSWD=mypassword
Adjust the values according to your preferences.
-
Generate the SSL Certificate and Key Create the following folder:
mkdir -p nginx/certs
Run the following command in your terminal to generate the SSL certificate (localhost.crt) and key (localhost.key). These commands create a certificate valid for 365 days:
openssl req -newkey rsa:2048 -nodes -keyout nginx/certs/localhost.key -x509 -days 365 -out nginx/certs/localhost.crt
-
Nginx Configuration
Ensure the
nginx/nginx.conf
file is configured to reverse proxy to the FastAPI application. Here's a simple example that proxies requests to the app service:server { listen 80; location / { proxy_pass http://app:9876; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }
-
Running the application Ensure that no service is listening on localhost at port 3306. Then from the root directory of your project, run:
sudo docker-compose up