FROM python:3.11-slim

WORKDIR /app
COPY . /app
RUN pip install --no-cache-dir /app

EXPOSE 8765

# The container must bind 0.0.0.0 so the published port is reachable.
# Non-loopback binding enables token auth by default: the access URL
# (with ?token=...) is printed in the container logs (`docker logs`).
# Set DREAMLOOP_NO_AUTH=1 only when the published port stays on the
# host's loopback (e.g. -p 127.0.0.1:8765:8765) AND no untrusted container
# shares this container's Docker network -- `-p` limits host exposure only,
# neighbouring containers can still reach 8765 directly.
# DREAMLOOP_TOKEN pins an explicit token instead of the generated one in
# .dreamloop/web_token.
CMD ["sh", "-c", "dreamloop init && dreamloop demo --if-empty --language ${DREAMLOOP_DEMO_LANGUAGE:-en} && dreamloop web --host 0.0.0.0 --port 8765"]
