Pamudu13 commited on
Commit
7110c78
·
verified ·
1 Parent(s): 53e65b7

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +55 -0
Dockerfile ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
55
+ CMD ["hypercorn", "app:app", "--bind", "0.0.0.0:7860"]