FROM python:3.11-slim

RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \
    libgl1-mesa-glx \
    libjemalloc-dev 

RUN useradd -m -s /bin/bash user && \
    mkdir -p /home/user && \
    chown -R user /home/user/

COPY ./ui/gradio /home/user/ui
COPY ./edgecraftrag /home/user/edgecraftrag

RUN mkdir -p /home/user/gradio_cache 
ENV GRADIO_TEMP_DIR=/home/user/gradio_cache

WORKDIR /home/user/ui
RUN pip install --no-cache-dir -r requirements.txt

USER user

RUN echo 'ulimit -S -n 999999' >> ~/.bashrc

ENTRYPOINT ["python", "ecragui.py"]
