# syntax=docker/dockerfile:1.4

from python:3.11-slim

RUN apt-get update && apt-get install -y git openssh-client && rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy the requirements file into the container
COPY requirements.txt .
COPY __init__.py .

# Copy code into the container
COPY ./ingestor ./ingestor

# Install the required packages
# Add github to known hosts
# This is needed for SSH to work
# The SSH key will NOT remain in the image
# IMPORTANT: this block requires BuildKit
# and the --ssh flag during docker build
RUN --mount=type=ssh \
    mkdir -p ~/.ssh && \
    ssh-keyscan github.com >> ~/.ssh/known_hosts && \
    pip install --no-cache-dir -r requirements.txt


# Run the application
CMD ["python", "-m", "ingestor.ingestor"]