AdarshJi commited on
Commit
45eb591
·
verified ·
1 Parent(s): 57f70ae

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -21
Dockerfile CHANGED
@@ -1,13 +1,13 @@
1
- # Use a small Debian-based Python image
2
  FROM python:3.9-slim
3
 
4
- # create non-root user (optional)
5
- RUN useradd -m -u 1000 user
6
- WORKDIR /app
7
 
8
- # Install system packages required by Chrome + basic tools
9
- # Install gnupg so we can add the Google signing key via gpg --dearmor
10
- RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
11
  ca-certificates \
12
  wget \
13
  gnupg \
@@ -25,26 +25,34 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
25
  libxrandr2 \
26
  libgbm1 \
27
  xdg-utils \
28
- wget \
29
- && rm -rf /var/lib/apt/lists/*
 
 
 
30
 
31
- # Add Google Chrome stable repository (secure method using signed-by keyring)
32
- RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor \
33
- > /usr/share/keyrings/google-linux-signing-key.gpg \
34
- && echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-linux-signing-key.gpg] http://dl.google.com/linux/chrome/deb/ stable main" \
35
  > /etc/apt/sources.list.d/google-chrome.list \
36
- && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends google-chrome-stable \
37
- && rm -rf /var/lib/apt/lists/*
 
38
 
39
- # Expose CHROME_BIN to the app (used by app.py)
40
- ENV CHROME_BIN=/usr/bin/google-chrome-stable
41
 
42
  # Copy and install Python dependencies
43
- COPY requirements.txt ./requirements.txt
44
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
45
 
46
- # Copy app
47
  COPY . /app
48
 
49
- # Ensure the entrypoint runs uvicorn; run as root (if you want non-root, adjust flags)
 
 
 
 
50
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Dockerfile
2
  FROM python:3.9-slim
3
 
4
+ # avoid interactive prompts during apt installs
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+ ENV CHROME_BIN=/usr/bin/google-chrome-stable
7
 
8
+ # Install system deps required for Chrome + basic tools and GPG for the key
9
+ RUN apt-get update \
10
+ && apt-get install -y --no-install-recommends \
11
  ca-certificates \
12
  wget \
13
  gnupg \
 
25
  libxrandr2 \
26
  libgbm1 \
27
  xdg-utils \
28
+ libxrender1 \
29
+ libxext6 \
30
+ libxshmfence1 \
31
+ libglib2.0-0 \
32
+ && rm -rf /var/lib/apt/lists/*
33
 
34
+ # Add Google Chrome repo key and install stable Chrome (use signed-by)
35
+ RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub \
36
+ | gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg \
37
+ && echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" \
38
  > /etc/apt/sources.list.d/google-chrome.list \
39
+ && apt-get update \
40
+ && apt-get install -y --no-install-recommends google-chrome-stable \
41
+ && rm -rf /var/lib/apt/lists/*
42
 
43
+ WORKDIR /app
 
44
 
45
  # Copy and install Python dependencies
46
+ COPY requirements.txt /app/requirements.txt
47
+ RUN pip install --no-cache-dir --upgrade pip \
48
+ && pip install --no-cache-dir -r /app/requirements.txt
49
 
50
+ # Copy app code
51
  COPY . /app
52
 
53
+ # Expose port (customize if needed)
54
+ EXPOSE 7860
55
+
56
+ # Run as root (simplifies running chrome in containers). If you want non-root,
57
+ # create a user and adapt permissions / flags accordingly.
58
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]