omniscientframework / Dockerfile
NexusInstruments's picture
Update Dockerfile
40742ab verified
# ─── Base Image ───────────────────────────────────────────────
FROM python:3.11-slim
# ─── System Setup ─────────────────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential git curl && \
rm -rf /var/lib/apt/lists/*
# ─── Non-root User ────────────────────────────────────────────
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# ─── Workdir ─────────────────────────────────────────────────
WORKDIR /app
# ─── Install Requirements ────────────────────────────────────
COPY --chown=user requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# ─── Copy Project and Install Package ─────────────────────────
COPY --chown=user . /app
RUN pip install -e .
# ─── Expose Ports ────────────────────────────────────────────
# Streamlit default = 7860
# Gradio default = 7860
# Chainlit default = 8000
EXPOSE 7860 8000
# ─── Environment Variable to Pick Framework ───────────────────
ENV APP_MODE=streamlit
# ─── Entrypoint ───────────────────────────────────────────────
# Detect whether app.py is at /app/app.py or /app/omniscientframework/app.py
CMD MODE=$(cat .app_mode 2>/dev/null || echo "$APP_MODE") && \
if [ "$MODE" = "streamlit" ]; then \
if [ -f "app.py" ]; then \
echo "🚀 Launching Streamlit (root-level app.py)"; \
streamlit run app.py --server.port=7860 --server.address=0.0.0.0; \
elif [ -f "omniscientframework/app.py" ]; then \
echo "🚀 Launching Streamlit (package-level app.py)"; \
streamlit run omniscientframework/app.py --server.port=7860 --server.address=0.0.0.0; \
else \
echo "❌ Error: app.py not found."; exit 1; \
fi; \
elif [ "$MODE" = "gradio" ]; then \
if [ -f "gradio_app.py" ]; then \
python gradio_app.py; \
elif [ -f "omniscientframework/gradio_app.py" ]; then \
python omniscientframework/gradio_app.py; \
else \
echo "❌ Error: gradio_app.py not found."; exit 1; \
fi; \
elif [ "$MODE" = "chainlit" ]; then \
if [ -f "chainlit_app.py" ]; then \
chainlit run chainlit_app.py --host 0.0.0.0 --port 8000; \
elif [ -f "omniscientframework/chainlit_app.py" ]; then \
chainlit run omniscientframework/chainlit_app.py --host 0.0.0.0 --port 8000; \
else \
echo "❌ Error: chainlit_app.py not found."; exit 1; \
fi; \
else \
echo "❌ Unknown APP_MODE: $MODE" && exit 1; \
fi