Soham0708 commited on
Commit
dbb2091
·
verified ·
1 Parent(s): 7d36fab

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -47
Dockerfile CHANGED
@@ -1,70 +1,61 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.11-slim
3
 
 
 
 
 
 
 
 
4
 
5
- # Install necessary system dependencies for Pyppeteer/Chrome
 
6
  RUN apt-get update && apt-get install -y \
 
 
7
  libnss3 \
8
- libxss1 \
9
- libasound2 \
10
  libatk1.0-0 \
11
  libatk-bridge2.0-0 \
12
  libcups2 \
13
- libdbus-1-3 \
14
- libdrm2 \
15
  libgbm1 \
16
- libnspr4 \
 
17
  libxcomposite1 \
18
  libxrandr2 \
19
- xdg-utils \
20
- libu2f-udev \
21
- libvulkan1 \
 
 
 
 
 
 
 
 
 
 
22
  fonts-liberation \
23
  libappindicator3-1 \
 
24
  lsb-release \
25
- wget \
26
- ca-certificates \
27
- libgtk-3-0 \
28
- --no-install-recommends
29
 
30
- # Install necessary packages and dependencies
31
- RUN apt-get update && \
32
- apt-get install -y \
33
- wget \
34
- gnupg \
35
- software-properties-common \
36
- xvfb \
37
- libxi6 \
38
- libgconf-2-4 \
39
- chromium \
40
- fonts-liberation \
41
- && rm -rf /var/lib/apt/lists/*
42
 
43
- # Install Google Chrome
44
- RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
45
- apt-get install -y ./google-chrome-stable_current_amd64.deb && \
46
- rm google-chrome-stable_current_amd64.deb
47
 
48
- # Clean up APT when done
49
- RUN apt-get clean && rm -rf /var/lib/apt/lists/*
50
-
51
- # Create a non-root user and set the environment path
52
- RUN useradd -m -u 1000 user
53
  USER user
54
- ENV PATH="/home/user/.local/bin:$PATH"
55
 
56
- # Set the working directory
57
- WORKDIR /app
58
-
59
- # Install Python dependencies as non-root user
60
  COPY --chown=user ./requirements.txt requirements.txt
61
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
62
 
63
- # Copy application code as non-root user
64
  COPY --chown=user . /app
65
 
66
- # Expose the port the application runs on
67
- EXPOSE 7860
68
-
69
- # Command to run the FastAPI application using xvfb-run
70
- CMD ["xvfb-run", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ FROM python:3.9
 
2
 
3
+ # Create a non-root user
4
+ RUN useradd -m -u 1000 user
5
+ USER user
6
+ ENV PATH="/home/user/.local/bin:$PATH"
7
+
8
+ # Set the working directory
9
+ WORKDIR /app
10
 
11
+ # Install dependencies required for Chromium
12
+ USER root
13
  RUN apt-get update && apt-get install -y \
14
+ wget \
15
+ unzip \
16
  libnss3 \
 
 
17
  libatk1.0-0 \
18
  libatk-bridge2.0-0 \
19
  libcups2 \
 
 
20
  libgbm1 \
21
+ libxkbcommon0 \
22
+ libpango-1.0-0 \
23
  libxcomposite1 \
24
  libxrandr2 \
25
+ libasound2 \
26
+ libpangocairo-1.0-0 \
27
+ libxdamage1 \
28
+ libgtk-3-0 \
29
+ libxshmfence1 \
30
+ libxcb1 \
31
+ libx11-xcb1 \
32
+ libxrender1 \
33
+ libxfixes3 \
34
+ libxcursor1 \
35
+ libxinerama1 \
36
+ libgl1 \
37
+ libgl1-mesa-glx \
38
  fonts-liberation \
39
  libappindicator3-1 \
40
+ xdg-utils \
41
  lsb-release \
42
+ && rm -rf /var/lib/apt/lists/*
 
 
 
43
 
44
+ # Install Chromium
45
+ RUN apt-get update && apt-get install -y chromium
 
 
 
 
 
 
 
 
 
 
46
 
47
+ # Set Chromium as the default browser
48
+ ENV CHROME_BIN=/usr/bin/chromium
 
 
49
 
50
+ # Switch back to the user context
 
 
 
 
51
  USER user
 
52
 
53
+ # Install Python dependencies
 
 
 
54
  COPY --chown=user ./requirements.txt requirements.txt
55
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
56
 
57
+ # Copy the application code
58
  COPY --chown=user . /app
59
 
60
+ # Define the command to run the application
61
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]