rajthakkar123's picture
Update Dockerfile
11f68f4 verified
FROM python:3.10-slim
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Create non-root user
RUN useradd -m -u 1000 appuser && \
mkdir -p /home/appuser/.local/share/applications && \
mkdir -p /home/appuser/.config && \
chown -R appuser:appuser /home/appuser
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
gnupg \
unzip \
curl \
ca-certificates \
# Chrome dependencies
libgl1-mesa-glx \
libglib2.0-0 \
libxrender1 \
libxext6 \
libx11-dev \
libnss3 \
libxss1 \
libasound2 \
libatk-bridge2.0-0 \
libdrm2 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
libgbm1 \
libxkbcommon0 \
libatspi2.0-0 \
libgtk-3-0 \
# Process management
procps \
&& rm -rf /var/lib/apt/lists/*
# Install Chrome (latest stable)
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-chrome.list && \
apt-get update && \
apt-get install -y google-chrome-stable && \
rm -rf /var/lib/apt/lists/*
# Verify Chrome installation
RUN google-chrome --version
# Create application directories with proper permissions
RUN mkdir -p /app/chrome_profile \
/app/chrome_crashes \
/tmp/chrome_debug_logs \
&& chown -R appuser:appuser /app \
&& chmod -R 755 /app
# Install Python dependencies
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /tmp/requirements.txt
# Copy application files
COPY . /app
RUN chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
WORKDIR /app
# Set HOME environment variable
ENV HOME=/home/appuser
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860 || exit 1
# Expose port
EXPOSE 7860
# Run the application
CMD ["python", "app.py"]