Jokica17 commited on
Commit
76d3d9e
·
1 Parent(s): c19d1fd

Added Docker configuration for backend and frontend services:

Browse files

- created `Dockerfile.backend` to containerize the backend with:
- Python 3.11 slim base image
- dependency installation from `requirements.txt`
- `PYTHONPATH` configuration and backend exposure on port 8000
- created `Dockerfile.frontend` to containerize the frontend with:
- Python 3.11 slim base image
- dependency installation from `requirements.txt`
- frontend exposure on port 7860
- added `docker-compose.yml` to orchestrate backend and frontend services:
- backend service builds from `Dockerfile.backend` with port mapping 8000:8000
- frontend service builds from `Dockerfile.frontend` with port mapping 7860:7860
- included volume mounts for local development
- ensured proper service dependencies and environment variables

Files changed (3) hide show
  1. Dockerfile.backend +20 -0
  2. Dockerfile.frontend +14 -0
  3. docker-compose.yml +30 -0
Dockerfile.backend ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Set the working directory
4
+ WORKDIR /usr/src/backend
5
+
6
+ # Copy the necessary files to the working directory
7
+ COPY config.py .
8
+ COPY app/ ./app/
9
+ COPY run.py .
10
+
11
+ # Add the project root to PYTHONPATH
12
+ ENV PYTHONPATH=/usr/src/backend:$PYTHONPATH
13
+
14
+ # Install dependencies
15
+ COPY app/requirements.txt .
16
+ RUN pip install --no-cache-dir -r requirements.txt
17
+
18
+ # Expose the port and run the backend
19
+ EXPOSE 8000
20
+ CMD ["python", "run.py"]
Dockerfile.frontend ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Set the working directory
4
+ WORKDIR /usr/src/frontend
5
+
6
+ # Copy the necessary files to the working directory
7
+ COPY fe/requirements.txt ./
8
+ RUN pip install --no-cache-dir -r requirements.txt
9
+ COPY fe/ ./fe/
10
+ COPY config.py .
11
+
12
+ # Expose the frontend port and run the frontend
13
+ EXPOSE 7860
14
+ CMD ["python", "-m", "fe.gradio_app"]
docker-compose.yml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.9'
2
+
3
+ services:
4
+ backend:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile.backend
8
+ container_name: searchengine-backend
9
+ ports:
10
+ - "8000:8000"
11
+ volumes:
12
+ - ./app:/usr/src/backend/app
13
+ - ./run.py:/usr/src/backend/run.py
14
+ environment:
15
+ - PYTHONUNBUFFERED=1
16
+ - BACKEND_HOST=0.0.0.0 # Ensure backend listens on all interfaces
17
+
18
+ frontend:
19
+ build:
20
+ context: .
21
+ dockerfile: Dockerfile.frontend
22
+ container_name: searchengine-frontend
23
+ ports:
24
+ - "7860:7860"
25
+ volumes:
26
+ - ./fe:/usr/src/frontend/fe
27
+ environment:
28
+ - PYTHONUNBUFFERED=1
29
+ depends_on:
30
+ - backend