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