Jokica17 commited on
Commit
6485a25
·
1 Parent(s): dd98df9

Docker setup refactor:

Browse files

- combined BE and FE dockerfiles into singe Dockerfile
- changed BACKEND_HOST

Files changed (5) hide show
  1. Dockerfile +26 -0
  2. Dockerfile.backend +0 -20
  3. Dockerfile.frontend +0 -14
  4. config.py +1 -2
  5. docker-compose.yml +0 -30
Dockerfile ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Set the working directory for the container
4
+ WORKDIR /usr/src/app
5
+
6
+ # Copy and install dependencies
7
+ COPY app/requirements.txt ./backend-requirements.txt
8
+ COPY fe/requirements.txt ./frontend-requirements.txt
9
+ RUN pip install --no-cache-dir -r backend-requirements.txt -r frontend-requirements.txt
10
+
11
+ # Set PYTHONPATH to ensure all modules are discoverable
12
+ ENV PYTHONPATH=/usr/src/app
13
+
14
+ # Copy backend files
15
+ COPY config.py ./config.py
16
+ COPY app/ ./app/
17
+ COPY run.py ./run.py
18
+
19
+ # Copy frontend files
20
+ COPY fe/ ./frontend/
21
+
22
+ # Expose ports for backend and frontend
23
+ EXPOSE 8000 7860
24
+
25
+ # Run both backend and frontend in parallel
26
+ CMD ["sh", "-c", "python run.py & python -m frontend.gradio_app"]
Dockerfile.backend DELETED
@@ -1,20 +0,0 @@
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 DELETED
@@ -1,14 +0,0 @@
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"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
config.py CHANGED
@@ -1,8 +1,7 @@
1
  # Configuration for Backend and Frontend
2
 
3
- # TODO: add FRONTEND_HOST and change BACKEND_HOST to work both local and within docker container
4
  # Backend Configuration
5
- BACKEND_HOST = "backend" # "0.0.0.0"
6
  BACKEND_PORT = 8000
7
 
8
  # Frontend Configuration
 
1
  # Configuration for Backend and Frontend
2
 
 
3
  # Backend Configuration
4
+ BACKEND_HOST = "0.0.0.0"
5
  BACKEND_PORT = 8000
6
 
7
  # Frontend Configuration
docker-compose.yml DELETED
@@ -1,30 +0,0 @@
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