FROM python:3.9 # Create a non-root user RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # Set the working directory WORKDIR /app # Install dependencies required for Chromium USER root RUN apt-get update && apt-get install -y \ wget \ unzip \ libnss3 \ libatk1.0-0 \ libatk-bridge2.0-0 \ libcups2 \ libgbm1 \ libxkbcommon0 \ libpango-1.0-0 \ libxcomposite1 \ libxrandr2 \ libasound2 \ libpangocairo-1.0-0 \ libxdamage1 \ libgtk-3-0 \ libxshmfence1 \ libxcb1 \ libx11-xcb1 \ libxrender1 \ libxfixes3 \ libxcursor1 \ libxinerama1 \ libgl1 \ libgl1-mesa-glx \ fonts-liberation \ libappindicator3-1 \ xdg-utils \ lsb-release \ && rm -rf /var/lib/apt/lists/* # Install Chromium RUN apt-get update && apt-get install -y chromium # Set Chromium as the default browser ENV CHROME_BIN=/usr/bin/chromium # Switch back to the user context USER user # Install Python dependencies COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the application code COPY --chown=user . /app # Define the command to run the application CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]