Update docker-compose for backend and reverse proxy
							parent
							
								
									13e9bf390b
								
							
						
					
					
						commit
						067c287fc4
					
				| 
						 | 
					@ -1,15 +1,12 @@
 | 
				
			||||||
# Use an official Python runtime as a parent image
 | 
					# Use an official Python runtime as a parent image
 | 
				
			||||||
FROM python:3.11-slim
 | 
					FROM python:3.11-slim
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Set the working directory in the container
 | 
					COPY requirements.txt /
 | 
				
			||||||
WORKDIR /app
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Install dependencies
 | 
					 | 
				
			||||||
COPY requirements.txt ./
 | 
					 | 
				
			||||||
RUN pip install --no-cache-dir -r requirements.txt
 | 
					RUN pip install --no-cache-dir -r requirements.txt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Copy the entire app into the container
 | 
					COPY . /app
 | 
				
			||||||
COPY . .
 | 
					WORKDIR /app
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Expose the Flask development server port
 | 
					# Expose the Flask development server port
 | 
				
			||||||
EXPOSE 5000
 | 
					EXPOSE 5000
 | 
				
			||||||
| 
						 | 
					@ -19,4 +16,4 @@ ENV FLASK_APP=app.py
 | 
				
			||||||
ENV FLASK_ENV=development
 | 
					ENV FLASK_ENV=development
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Command to run the Flask application
 | 
					# Command to run the Flask application
 | 
				
			||||||
CMD ["flask", "run", "--host=0.0.0.0", "--port=5000"]
 | 
					CMD ["flask", "run", "--host=0.0.0.0", "--port=5000", "--debug"]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,11 +1,46 @@
 | 
				
			||||||
 | 
					version: '3.9'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
services:
 | 
					services:
 | 
				
			||||||
 | 
					  # Flask service
 | 
				
			||||||
  backend:
 | 
					  backend:
 | 
				
			||||||
    build: ./backend
 | 
					    container_name: backend
 | 
				
			||||||
 | 
					    build:
 | 
				
			||||||
 | 
					      context: ./backend-flask
 | 
				
			||||||
 | 
					      #image: jazzdd/alpine-flask:python3
 | 
				
			||||||
    ports:
 | 
					    ports:
 | 
				
			||||||
      - 5000:5000
 | 
					      - ":5000"
 | 
				
			||||||
    volumes:
 | 
					    volumes:
 | 
				
			||||||
      - ./backend:/app
 | 
					      - ./backend-flask:/app
 | 
				
			||||||
      - ./sqlite3:/app/sqlite3
 | 
					    networks:
 | 
				
			||||||
    command: uvicorn src.main:app --reload --host 0.0.0.0 --port 5000
 | 
					      - dev-network
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # Vue + Vite service
 | 
				
			||||||
 | 
					  frontend:
 | 
				
			||||||
 | 
					    container_name: frontend
 | 
				
			||||||
 | 
					    build:
 | 
				
			||||||
 | 
					      context: ./availabili.tf
 | 
				
			||||||
 | 
					    ports:
 | 
				
			||||||
 | 
					      - ":5173"
 | 
				
			||||||
    environment:
 | 
					    environment:
 | 
				
			||||||
      - DB_URI=sqlite:///./sqlite3/db.sqlite3
 | 
					      VITE_API_URL: http://localhost:8000  # API endpoint
 | 
				
			||||||
 | 
					    volumes:
 | 
				
			||||||
 | 
					      - ./availabili.tf:/app
 | 
				
			||||||
 | 
					    networks:
 | 
				
			||||||
 | 
					      - dev-network
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # NGINX service
 | 
				
			||||||
 | 
					  nginx:
 | 
				
			||||||
 | 
					    image: nginx:latest
 | 
				
			||||||
 | 
					    ports:
 | 
				
			||||||
 | 
					      - "8000:80"
 | 
				
			||||||
 | 
					    volumes:
 | 
				
			||||||
 | 
					      - ./nginx:/etc/nginx/conf.d
 | 
				
			||||||
 | 
					    depends_on:
 | 
				
			||||||
 | 
					      - backend
 | 
				
			||||||
 | 
					      - frontend
 | 
				
			||||||
 | 
					    networks:
 | 
				
			||||||
 | 
					      - dev-network
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					networks:
 | 
				
			||||||
 | 
					  dev-network:
 | 
				
			||||||
 | 
					    driver: bridge
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,24 @@
 | 
				
			||||||
 | 
					server {
 | 
				
			||||||
 | 
					    listen 80;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Proxy for the Vite frontend
 | 
				
			||||||
 | 
					    location / {
 | 
				
			||||||
 | 
					        proxy_pass http://frontend:5173;
 | 
				
			||||||
 | 
					        proxy_set_header Host $host;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        proxy_http_version 1.1;
 | 
				
			||||||
 | 
					        proxy_set_header Upgrade $http_upgrade;
 | 
				
			||||||
 | 
					        proxy_set_header Connection "upgrade";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Proxy for the Flask backend API
 | 
				
			||||||
 | 
					    location /api/ {
 | 
				
			||||||
 | 
					        proxy_pass http://backend:5000;
 | 
				
			||||||
 | 
					        proxy_set_header Host $host;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    location /apidoc/ {
 | 
				
			||||||
 | 
					        proxy_pass http://backend:5000;
 | 
				
			||||||
 | 
					        proxy_set_header Host $host;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue