AEGIS-SECURE-API / Dockerfile
Akshatbhatt515334's picture
Update Dockerfile
86f0adb verified
FROM python:3.9
# Set the working directory
WORKDIR /app
# 1. Copy requirements first to cache dependencies
COPY ./requirements.txt requirements.txt
# 2. Install Python dependencies (Running as root to ensure system-wide availability)
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# 3. CRITICAL: Install Playwright System Dependencies
# This command downloads the necessary Linux libraries (libnss, libatk, etc.)
# required to run the Chromium browser engine. This MUST run as root.
RUN playwright install-deps chromium
# 4. Create a non-root user (Hugging Face Spaces / Security Best Practice)
RUN useradd -m -u 1000 user
# 5. Switch to the new user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# 6. Install the Chromium Browser Binary
# We run this as 'user' so the browser is installed in /home/user/.cache/ms-playwright
# where the application has permission to access it.
RUN playwright install chromium
# 7. Copy the application code with correct ownership
COPY --chown=user . /app
# 8. Run the application
# Note: Ensure your main file is actually named 'app1.py'.
# If your file is 'app2.py' (as seen in your logs), change 'app1:app' to 'app2:app'
CMD ["uvicorn", "app1:app", "--host", "0.0.0.0", "--port", "7860"]