# SPDX-License-Identifier: Apache-2.0
FROM ghcr.io/living-proof-labs/livingproof:2.3.3-development@sha256:4445637d1cbe24ae75a303fe2587225da80a628a101c115c8de5a410b88b8262 AS development
# Use Common's editable environment and cache, not Living Proof's.
# Compose may run with the mounted checkout owner's UID rather than vscode.
USER root
RUN mkdir -p /opt/common-venv /opt/common-cache && chmod 1777 /opt/common-venv /opt/common-cache
ENV UV_PROJECT_ENVIRONMENT=/opt/common-venv UV_CACHE_DIR=/opt/common-cache
ENV PATH="/opt/common-venv/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin"
WORKDIR /workspace/common
USER vscode


# Browser system libraries are development-only; the common library remains pure Python.
FROM development AS documentation-test
USER root
COPY pyproject.toml uv.lock /tmp/common-tools/
RUN cd /tmp/common-tools && \
    UV_CACHE_DIR=/tmp/common-tools/cache UV_PROJECT_ENVIRONMENT=/tmp/common-tools/venv uv sync --locked --no-install-project --group docs-test --no-python-downloads && \
    /tmp/common-tools/venv/bin/playwright install-deps chromium && \
    rm -rf /tmp/common-tools
ENV PLAYWRIGHT_BROWSERS_PATH=/opt/common-browsers
RUN mkdir -p /opt/common-browsers && chmod 1777 /opt/common-browsers
USER vscode
