FROM artixlinux/artixlinux:base-dinit

# Install necessary build tools
RUN pacman -Suy --noconfirm base-devel git wget sudo make pacman-contrib

# Config to use 16 thread for building
RUN printf 'MAKEFLAGS="-j16"\n' > /etc/makepkg.conf.d/j16.conf

# Create a build user
RUN useradd -m builduser \
    && passwd -d builduser \
    && printf 'builduser ALL=(ALL) ALL\n' >> /etc/sudoers

# Set working directory
WORKDIR /home/builduser

# Build the package as the non-root user
# -s: install missing dependencies
# -c: clean build directory after successful build
# --noconfirm: auto-confirm prompts
USER builduser

# Do NOT copy source code or run makepkg here.
# Leave the container ready to accept any mounted directory.
CMD ["bash"]

