48 lines
1.3 KiB
Docker
48 lines
1.3 KiB
Docker
FROM python:3.9-slim
|
|
|
|
# Install required system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
wget \
|
|
gnupg2 \
|
|
procps \
|
|
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome-keyring.gpg \
|
|
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | tee /etc/apt/sources.list.d/google-chrome.list \
|
|
&& apt-get update \
|
|
&& apt-get install -y \
|
|
google-chrome-stable \
|
|
fonts-ipafont-gothic \
|
|
fonts-wqy-zenhei \
|
|
fonts-thai-tlwg \
|
|
fonts-kacst \
|
|
fonts-freefont-ttf \
|
|
libxss1 \
|
|
xvfb \
|
|
--no-install-recommends \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
# Verify Chrome installation
|
|
&& google-chrome --version
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy requirements first to leverage Docker cache
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy the rest of the application
|
|
COPY . .
|
|
|
|
# Set environment variables
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV API_KEY=""
|
|
|
|
# Create a non-root user and switch to it
|
|
RUN useradd -m puppeteer && chown -R puppeteer:puppeteer /app
|
|
USER puppeteer
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Run the application
|
|
CMD ["python", "main.py"]
|