FROM python:3.11-slim

WORKDIR /app

# Copy only the necessary subdirectory
COPY . /app

# Install system dependencies (for psycopg2 and similar packages)
RUN apt-get update && apt-get install -y \
    curl \
    gnupg \
    gcc \
    libpq-dev \
    && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
    && apt-get install -y nodejs \
    && npm install -g typescript \
    && rm -rf /var/lib/apt/lists/*

# Install Rust using rustup in non-interactive mode
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Ensure that the Rust binaries are in PATH
ENV PATH="/root/.cargo/bin:${PATH}"

# Confirm installation by printing Rust and Cargo versions
RUN rustc --version && cargo --version
RUN npm install -g typescript
RUN npm install

# Set up venv, install requirements
RUN python -m venv /py_venv \
    && /py_venv/bin/pip install --upgrade pip \
    && /py_venv/bin/pip install -r post_processing/py/requirements.txt

ENV PYTHONPATH=/app/post_processing/py/utils:/app/post_processing/py/graphs

# Run the script using the virtual environment
WORKDIR /app/post_processing/py
CMD ["/py_venv/bin/python", "cname_worker.py"]
