-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (55 loc) · 2.1 KB
/
Dockerfile
File metadata and controls
67 lines (55 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Use Python 3.10 as base image
FROM python:3.10-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
wget \
gnupg \
unzip \
wkhtmltopdf \
apt-transport-https \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install Google Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
&& apt-get update \
&& apt-get install -y google-chrome-stable \
&& rm -rf /var/lib/apt/lists/*
# Install ChromeDriver
RUN CHROME_VERSION=$(google-chrome --version | awk '{print $3}' | awk -F'.' '{print $1}') \
&& wget -q "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/${CHROME_VERSION}.0.6943.126/linux64/chromedriver-linux64.zip" \
&& unzip chromedriver-linux64.zip \
&& mv chromedriver-linux64/chromedriver /usr/local/bin/ \
&& rm -rf chromedriver-linux64.zip chromedriver-linux64 \
&& chmod +x /usr/local/bin/chromedriver
# Set working directory
WORKDIR /app
# Copy requirements first to leverage Docker cache
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Download NLTK data
RUN python -m nltk.downloader -d /usr/local/share/nltk_data punkt vader_lexicon
RUN chmod -R 777 /usr/local/share/nltk_data
# Set NLTK data path
ENV NLTK_DATA=/usr/local/share/nltk_data
# Copy the rest of the application
COPY . .
# Create necessary directories and set permissions
RUN mkdir -p data/visualizations data/reports \
&& chmod -R 777 data \
&& mkdir -p /var/lib/chrome \
&& chown -R root:root /var/lib/chrome \
&& chmod -R 777 /var/lib/chrome \
&& mkdir -p /tmp/.X11-unix \
&& chmod 1777 /tmp/.X11-unix \
&& mkdir -p /.config/matplotlib \
&& chmod -R 777 /.config
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV DISPLAY=:99
ENV CHROME_BIN=/usr/bin/google-chrome
ENV CHROME_PATH=/usr/bin/google-chrome
ENV MPLCONFIGDIR=/tmp/matplotlib
# Command to run the application
ENTRYPOINT ["python", "main.py"]