FROM ollama/ollama:latest # Change to custom app directory WORKDIR /app ENV HOME=/app # Add ollama user and ensure home + ollama directories RUN groupadd -r ollama && useradd -r -g ollama ollama \ && mkdir -p /app/.ollama /app/.local /app/sql_files \ && chown -R ollama:ollama /app # Install packages RUN apt-get update && apt-get install -y \ build-essential \ curl \ software-properties-common \ git \ python3 \ python3-pip \ python3-venv \ netcat-openbsd \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt ./ COPY src/ ./src/ COPY entrypoint.sh /usr/local/bin/entrypoint.sh COPY frontend/app/dist/ ./frontend/app/dist/ RUN python3 -m venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" RUN pip install --no-cache-dir -r requirements.txt RUN chmod +x /usr/local/bin/entrypoint.sh RUN chmod -R 777 /app/.local /app/.ollama /app/sql_files USER ollama ENV OLLAMA_HOST=0.0.0.0:11434 ENV PORT=7860 EXPOSE 11434 7860 5000 HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1 ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]