# Use a base image with a recent Linux distribution
FROM ubuntu:22.04

# Install necessary dependencies as root
RUN apt-get update && apt-get install -y --no-install-recommends build-essential cmake qtbase5-dev libqt5waylandclient5-dev libpipewire-0.3-dev libgirepository1.0-dev pkg-config git libx11-dev libxext-dev libxdamage-dev libxss-dev libxrender-dev clang wayland-scanner++ && rm -rf /var/lib/apt/lists/*
RUN find /usr -name QNativeInterface.h


# Set up a non-root user
RUN useradd -m builder
# Copy the project source code into the container
# Copy as root first, then change ownership
COPY . /home/builder/Hyperion_Grabber_X11_QT
RUN chown -R builder:builder /home/builder/Hyperion_Grabber_X11_QT

USER builder
WORKDIR /home/builder/Hyperion_Grabber_X11_QT

# Create a build directory and configure cmake
RUN rm -rf build && mkdir build
WORKDIR build
RUN cmake .. -DCMAKE_CXX_COMPILER=clang++

# You can add commands here to run tests or package the application
# For now, we'll just ensure it builds successfully
CMD ["./wayland_poc"]
