Pamudu13 commited on
Commit
b1a8325
·
verified ·
1 Parent(s): 4dd1d1c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +41 -6
Dockerfile CHANGED
@@ -1,19 +1,54 @@
1
  # Use an official Python image as a base
2
  FROM python:3.9
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  # Set the working directory
5
  WORKDIR /app
6
 
7
- # Copy the current directory contents into the container at /app
8
- COPY . /app
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- # Copy the requirements file into the container
11
  COPY requirements.txt .
12
 
13
- # Install dependencies from requirements.txt
14
- RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
 
 
 
 
 
 
15
 
16
- # Expose the port Hypercorn will run on (Hugging Face typically uses 7860)
17
  EXPOSE 7860
18
 
19
  # Run the app with Hypercorn
 
1
  # Use an official Python image as a base
2
  FROM python:3.9
3
 
4
+ # Set environment variables
5
+ ENV PYTHONUNBUFFERED=1 \
6
+ PORT=7860 \
7
+ PYTHONPATH=/app \
8
+ HOME=/home/chrome \
9
+ CHROME_BIN=/usr/bin/google-chrome
10
+
11
+ # Create chrome user
12
+ RUN mkdir -p /home/chrome && \
13
+ groupadd -r chrome && \
14
+ useradd -r -g chrome -G audio,video chrome && \
15
+ mkdir -p /home/chrome/Downloads && \
16
+ chown -R chrome:chrome /home/chrome
17
+
18
  # Set the working directory
19
  WORKDIR /app
20
 
21
+ # Install system dependencies including Chrome
22
+ RUN apt-get update && apt-get install -y \
23
+ build-essential \
24
+ wget \
25
+ gnupg \
26
+ unzip \
27
+ xvfb \
28
+ && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
29
+ && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
30
+ && apt-get update \
31
+ && apt-get install -y google-chrome-stable \
32
+ && chown -R chrome:chrome /usr/bin/google-chrome \
33
+ && rm -rf /var/lib/apt/lists/*
34
 
35
+ # Copy requirements file
36
  COPY requirements.txt .
37
 
38
+ # Install Python dependencies
39
+ RUN pip install --no-cache-dir -r requirements.txt \
40
+ && pip install --no-cache-dir hypercorn
41
+
42
+ # Copy the current directory contents into the container
43
+ COPY . /app
44
+
45
+ # Set permissions
46
+ RUN chown -R chrome:chrome /app
47
+
48
+ # Switch to chrome user
49
+ USER chrome
50
 
51
+ # Make port 7860 available to the world outside this container
52
  EXPOSE 7860
53
 
54
  # Run the app with Hypercorn