# User mode UAT testing for systemg
ARG RUST_IMAGE=rust:1.96.0-bullseye
ARG RUNTIME_IMAGE=ubuntu:22.04
FROM ${RUST_IMAGE} AS builder

WORKDIR /app
COPY . .
RUN cargo build --release

FROM ${RUNTIME_IMAGE}

# Install runtime requirements for user-mode tests
RUN apt-get update && apt-get install -y \
    nodejs \
    npm \
    python3 \
    && rm -rf /var/lib/apt/lists/*

# Copy local sysg binary built from the current workspace.
COPY --from=builder /app/target/release/sysg /usr/local/bin/
RUN chmod +x /usr/local/bin/sysg

# Create test user for user-mode testing
RUN useradd -m -s /bin/bash testuser
USER testuser
WORKDIR /home/testuser

# Copy test projects and scripts
COPY --chown=testuser:testuser tests/docker/user/ /home/testuser/

# Run the full user-mode UAT suite (matches the CI Dockerfile).
CMD ["/bin/bash", "run_user_tests.sh"]
