# We use 3.10-slim to keep the image size small but compatible with PyTorch FROM python:3.10-slim-bookworm # 1. Install System Dependencies # - openjdk-17-jdk: Required for Joern to run # - wget, curl, unzip: For downloading Joern # - git: For version control if needed RUN apt-get update && \ apt-get install -y \ openjdk-17-jdk \ wget \ curl \ unzip \ git \ && rm -rf /var/lib/apt/lists/* # 2. Set Environment Variables ENV PYTHONDONTWRITEBYTECODE=1 # Keep Python output unbuffered ENV PYTHONUNBUFFERED=1 # Set Java Home (For Joern) ENV JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64" # 3. Set Working Directory WORKDIR /app # 4. Install Joern RUN mkdir -p /app/joern && \ cd /app/joern && \ wget -q https://github.com/joernio/joern/releases/latest/download/joern-cli.zip && \ unzip joern-cli.zip && \ rm joern-cli.zip # Add Joern to PATH so we can use 'joern-parse' directly ENV PATH="/app/joern/joern-cli:${PATH}" # 5. Copy Python Requirements COPY requirements.txt . # 6. Install Python Dependencies # Use the --no-cache-dir option to keep the image small RUN pip install --no-cache-dir -r requirements.txt # 7. Copy Application Code COPY . . # 8. Create a writable directory for temporary graphs # Hugging Face runs as a non-root user, so need to ensure permissions RUN mkdir -p /app/temp_workspace && \ chmod 777 /app/temp_workspace # 9.Start Command CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]