Shreyas094 commited on
Commit
8772e69
·
verified ·
1 Parent(s): c7a9051

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -46
Dockerfile CHANGED
@@ -1,46 +1,17 @@
1
- # Stage 1: Browser and build tools installation
2
- FROM python:3.11.4-slim-bullseye AS install-browser
3
-
4
- # Install Chromium, Chromedriver, Firefox, Geckodriver, and build tools in one layer
5
- RUN apt-get update && \
6
- apt-get satisfy -y "chromium, chromium-driver (>= 115.0)" && \
7
- apt-get install -y --no-install-recommends firefox-esr wget build-essential && \
8
- wget https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz && \
9
- tar -xvzf geckodriver-v0.33.0-linux64.tar.gz && \
10
- chmod +x geckodriver && \
11
- mv geckodriver /usr/local/bin/ && \
12
- rm geckodriver-v0.33.0-linux64.tar.gz && \
13
- chromium --version && chromedriver --version && \
14
- rm -rf /var/lib/apt/lists/* # Clean up apt lists to reduce image size
15
-
16
- # Stage 2: Python dependencies installation
17
- FROM install-browser AS gpt-researcher-install
18
-
19
- ENV PIP_ROOT_USER_ACTION=ignore
20
- WORKDIR /usr/src/app
21
-
22
- # Copy and install Python dependencies in a single layer to optimize cache usage
23
- COPY ./requirements.txt ./requirements.txt
24
- COPY ./multi_agents/requirements.txt ./multi_agents/requirements.txt
25
-
26
- RUN pip install --no-cache-dir -r requirements.txt && \
27
- pip install --no-cache-dir -r multi_agents/requirements.txt
28
-
29
- # Stage 3: Final stage with non-root user and app
30
- FROM gpt-researcher-install AS gpt-researcher
31
-
32
- # Create a non-root user for security
33
- RUN useradd -ms /bin/bash gpt-researcher && \
34
- chown -R gpt-researcher:gpt-researcher /usr/src/app
35
-
36
- USER gpt-researcher
37
- WORKDIR /usr/src/app
38
-
39
- # Copy the rest of the application files with proper ownership
40
- COPY --chown=gpt-researcher:gpt-researcher ./ ./
41
-
42
- # Expose the application's port
43
- EXPOSE 8000
44
-
45
- # Define the default command to run the application
46
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.9-slim
3
+
4
+ # Set the working directory in the container
5
+ WORKDIR /app
6
+
7
+ # Copy the current directory contents into the container at /app
8
+ COPY . /app
9
+
10
+ # Install any needed dependencies
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Expose the port the app runs on
14
+ EXPOSE 8000
15
+
16
+ # Run the FastAPI app using Uvicorn
17
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]