# Containerfile for end-to-end testing of the flow CLI.
#
# Builds a minimal Debian image with python + git, copies the flow source in,
# installs it via pip, and creates a non-root user (flow refuses to run as root).
#
# Build context expected to be the flow-cli repo root. Example:
#   podman build -f tests/e2e/Containerfile -t flow-e2e .
#
FROM debian:bookworm-slim

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        git \
        python3 \
        python3-venv \
        python3-pip \
        sudo \
        ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user; flow refuses to run as uid 0.
RUN useradd --create-home --shell /bin/bash flowuser \
    && echo "flowuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Copy the flow source and install it for the non-root user.
WORKDIR /opt/flow-src
COPY --chown=flowuser:flowuser . /opt/flow-src

USER flowuser
ENV PATH="/home/flowuser/.local/bin:${PATH}"

RUN pip3 install --user --break-system-packages -e /opt/flow-src

WORKDIR /home/flowuser
ENTRYPOINT ["/bin/bash"]
