FROM archlinux:base-devel

# Install dependencies
RUN pacman -Syu --noconfirm && \
    pacman -S --noconfirm \
    git \
    openssh \
    gnupg \
    python \
    python-pip \
    python-requests \
    python-yaml \
    python-gitpython \
    python-pytest \
    python-pytest-cov && \
    # Clean up
    pacman -Scc --noconfirm && \
    rm -rf /var/cache/pacman/pkg/* && \
    rm -rf /var/lib/pacman/sync/*

# Create non-root user for better security and set up permissions
RUN useradd -m -s /bin/bash runner && \
    echo "runner ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
    # Create all required directories with proper permissions
    mkdir -p /__w/_temp/_runner_file_commands && \
    mkdir -p /__w/_actions && \
    mkdir -p /__w/_temp/_github_home && \
    mkdir -p /__w/_temp/_github_workflow && \
    # Set permissions recursively
    chown -R runner:runner /__w && \
    chmod -R 777 /__w

# Switch to non-root user
USER runner
WORKDIR /home/runner

# Pre-configure git for container reuse
RUN git config --global --add safe.directory '*' 