simoncck commited on
Commit
6a877d9
·
verified ·
1 Parent(s): a985955

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +49 -0
Dockerfile ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python slim image as base
2
+ FROM python:3.11-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONUNBUFFERED=1
6
+ ENV DEBIAN_FRONTEND=noninteractive
7
+
8
+ # Install system dependencies for Chrome and Selenium
9
+ RUN apt-get update && apt-get install -y \
10
+ wget \
11
+ gnupg \
12
+ unzip \
13
+ curl \
14
+ xvfb \
15
+ && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
16
+ && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
17
+ && apt-get update \
18
+ && apt-get install -y google-chrome-stable \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ # Install ChromeDriver
22
+ RUN CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` \
23
+ && wget -N http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \
24
+ && unzip chromedriver_linux64.zip \
25
+ && rm chromedriver_linux64.zip \
26
+ && mv chromedriver /usr/local/bin/chromedriver \
27
+ && chmod +x /usr/local/bin/chromedriver
28
+
29
+ # Set working directory
30
+ WORKDIR /app
31
+
32
+ # Copy requirements first for better caching
33
+ COPY requirements.txt .
34
+
35
+ # Install Python dependencies
36
+ RUN pip install --no-cache-dir -r requirements.txt
37
+
38
+ # Copy application code
39
+ COPY . .
40
+
41
+ # Expose port
42
+ EXPOSE 7860
43
+
44
+ # Create non-root user for security
45
+ RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
46
+ USER appuser
47
+
48
+ # Run the application
49
+ CMD ["python", "app.py"]