Space stuck on “Starting” — no visible logs, DB download & Streamlit app

Hello, my Hugging Face Space “SuhasGholkar/capsproj” is stuck on “Starting” even though the build succeeds. No errors appear in either the Build logs or Runtime logs. My own logging statements in app.py also do not show up.

I’ve attached my main files (app.py, Dockerfile) below. The app is a Streamlit application that:

  • Ensures an SQLite DB exists (downloads from Hub if missing).

  • Runs a chatbot UI with multiple tabs and MIS reporting.

  • Uses openai for model calls.

DocketFile Contents -

# ---- Base image ----
FROM python:3.10-slim
# Useful runtime env
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
# ---- Workdir ----
WORKDIR /app
# ---- Python deps ----
COPY requirements.txt .
# Keep OS deps minimal (only if needed for some wheels)
RUN apt-get update && apt-get install -y --no-install-recommends \
&& pip install --no-cache-dir -r requirements.txt \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/*
# ---- App code ----
COPY . .
COPY olist.sqlite /tmp/olist.sqlite
# Streamlit & Matplotlib writable caches (mirrors the header you added in app.py)
ENV HOME=/app \
XDG_CACHE_HOME=/app/.cache \
MPLCONFIGDIR=/app/.mplconfig \
STREAMLIT_SERVER_HEADLESS=true
RUN mkdir -p /app/.streamlit /app/.cache /app/.mplconfig
# (Optional) Streamlit server config – having this file in the repo also works
# RUN printf “[server]\nheadless = true\nport = 7860\naddress = \“0.0.0.0\”\nenableCORS = false\nenableXsrfProtection = false\n” > /app/.streamlit/config.toml
# ---- Network ----
EXPOSE 7860
# ---- Start ----
CMD [“streamlit”, “run”, “app.py”, “–server.port=7860”, “–server.address=0.0.0.0”, “–server.enableCORS=false”]

https://huggingface.co/spaces/SuhasGholkar/capsproj/resolve/main/app.py

Steps already tried:

  • Verified requirements.txt contains all imports (streamlit, pandas, matplotlib, dateparser, openai, huggingface_hub).

  • Rebuilt Space.

2 Likes

When setting WORKDIR in Dockerfile, it may be safer to write useradd first.

I applied the suggestion and made relevant changes in Dockerfile. Pls find below the updated Dockerfile. However post this change also the application is stuck in “Starting” . There are no errors in Build and Container logs. Pls let me know if any more change may be needed . Thanks for suggestion.

DOCKERFILE

# ---- Base image ----
FROM python:3.10-slim
# Useful runtime env
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
# ---- Python deps ----
COPY requirements.txt .
# Keep OS deps minimal (only if needed for some wheels)
RUN apt-get update && apt-get install -y --no-install-recommends \
&& pip install --no-cache-dir -r requirements.txt \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/*
# Create a new user after installing dependencies
RUN useradd --create-home --shell /bin/bash myuser
# Set the working directory, owned by the new user
WORKDIR /app
RUN chown -R myuser:myuser /app
# Switch to the new user before running the app
USER myuser
# ---- App code ----
COPY . .
# Streamlit & Matplotlib writable caches (mirrors the header you added in app.py)
ENV HOME=/app \
XDG_CACHE_HOME=/app/.cache \
MPLCONFIGDIR=/app/.mplconfig \
STREAMLIT_SERVER_HEADLESS=true
RUN mkdir -p /app/.streamlit /app/.cache /app/.mplconfig
# ---- Network ----
EXPOSE 7860
# ---- Start ----
CMD [“streamlit”, “run”, “app.py”, “–server.port=7860”, “–server.address=0.0.0.0”, “–server.enableCORS=false”]
1 Like

Since the container seems to run with user ID 1000, I think you need to specify the user ID when doing useradd.