FROM golang:1.21

WORKDIR /tmp

# Install apt packages
RUN apt-get update && apt-get install --no-install-recommends -y \
  pip \
  && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
  && rm -rf /var/lib/apt/lists/*

# Dash → Bash
RUN echo "dash dash/sh boolean false" | debconf-set-selections
RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash

RUN useradd -u 1234 -d /home/ci -m ci
USER ci

ENV PATH="$PATH:/home/ci/.local/bin"

COPY .pre-commit-config.yaml .

RUN pip install "pre-commit==3.1.1" \
  && git init . \
  && pre-commit install-hooks \
  && rm -rf /tmp/*