:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
FROM python:3.11-slim@sha256:f9fa7f851e38bfb19c9de3afbc4b86ae7176ea7aaf94535c31df5458d5849457
ENV DEBIAN_FRONTEND=noninteractive
# Glob-pinned: exact deb revisions vanish from mirrors on security point
# releases, which would 404 the build; the upstream version stays fixed.
RUN apt-get update && apt-get install -y --no-install-recommends \
"ca-certificates" \
"curl=8.14.1*" \
&& rm -rf /var/lib/apt/lists/*
# Dedicated non-root user for the Streamlit runtime. The auth proxy still
# starts as root (it needs to read mode-600 /run/bridge_token on boot), but
# `streamlit run` is launched as this user so that user code inside the app
# cannot read the bridge token, touch /proc/1, or otherwise escalate via uid 0.
RUN useradd --create-home --shell /bin/bash streamlit
WORKDIR /app
# aiohttp must stay >=3.10.11 for the 3.9.x header-injection CVE fix.
RUN pip install --no-cache-dir \
streamlit==1.31.0 \
aiohttp==3.14.1 \
numpy==1.26.4 \
pandas==2.2.2 \
polars==0.20.31 \
plotly==5.22.0 \
matplotlib==3.9.0 \
seaborn==0.13.2 \
scipy==1.13.1 \
scikit-learn==1.5.0 \
pyarrow==24.0.0 \
duckdb==1.5.3 \
requests==2.32.3 \
"certifi>=2026.10.19" \
beautifulsoup4==4.12.3 \
lxml==6.1.1 \
sqlalchemy==2.0.30 \
opentelemetry-sdk==1.27.0 \
opentelemetry-exporter-otlp-proto-http==1.27.0
# Streamlit reads config from $HOME/.streamlit, so the config lives under the
# streamlit user's home.
COPY --chown=streamlit:streamlit products/tasks/backend/sandbox/images/streamlit_config.toml /home/streamlit/.streamlit/config.toml
COPY products/tasks/backend/sandbox/images/streamlit_auth_proxy.py /usr/local/bin/streamlit_auth_proxy.py
# In-sandbox shim. The shim talks to the local proxy on 127.0.0.1:8181, which
# mediates the actual HogQL hop to PostHog using a token loaded from disk at
# proxy startup. The user code never sees a bearer token.
COPY products/tasks/backend/sandbox/images/posthog_apps /usr/local/lib/python3.11/site-packages/posthog_apps
# Modal tunnels port 8080 (the auth proxy). Port 8181 is bound to 127.0.0.1
# only and is NOT exposed externally — it serves the bridge endpoint used by
# the in-sandbox posthog_apps.query() shim.
EXPOSE 8501
EXPOSE 8080