FROM python:3.12-slim | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
wget \ | |
ca-certificates \ | |
libgl1-mesa-glx \ | |
libegl1-mesa \ | |
libfontconfig1 \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Set the working directory in the container | |
WORKDIR /app | |
# --- Define cache directory early for clarity --- | |
ARG HF_CACHE_DIR_ARG=/app/.cache | |
ENV HF_HOME=${HF_CACHE_DIR_ARG} | |
ENV HF_DATASETS_CACHE=${HF_CACHE_DIR_ARG}/datasets | |
ENV TRANSFORMERS_CACHE=${HF_CACHE_DIR_ARG}/transformers | |
# Create the cache directories and make them writable | |
RUN mkdir -p ${HF_DATASETS_CACHE} && chmod -R 777 ${HF_CACHE_DIR_ARG} | |
COPY setup.sh . | |
COPY requirements.txt . | |
COPY app.py . | |
COPY src/ ./src/ | |
RUN chmod +x setup.sh && ./setup.sh | |
# make the directories | |
RUN mkdir -p /app/local_hf_downloads && chmod 777 /app/local_hf_downloads | |
RUN mkdir -p /app/temp_dir_for_exec_code && chmod 777 /app/temp_dir_for_exec_code | |
# Install Python dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Environment variables for MiniZinc | |
ENV MZN_DIR=/opt/minizinc | |
ENV PATH="${MZN_DIR}/bin:${PATH}" | |
ENV LD_LIBRARY_PATH="${MZN_DIR}/lib:${LD_LIBRARY_PATH}" | |
ENV QT_PLUGIN_PATH="${MZN_DIR}/plugins:${QT_PLUGIN_PATH}" | |
# Expose the port Gradio runs on | |
EXPOSE 7860 | |
CMD ["python", "app.py"] |