FROM docker.io/golang:1.23 AS build
WORKDIR /src
RUN git clone https://git.sr.ht/~emersion/soju . && git checkout v0.8.0
COPY hostname-cloak.patch .
RUN git apply hostname-cloak.patch
RUN CGO_ENABLED=0 go build -o /soju ./cmd/soju
RUN CGO_ENABLED=0 go build -o /sojuctl ./cmd/sojuctl

FROM registry.access.redhat.com/ubi9-minimal
COPY --from=build /soju /usr/local/bin/
COPY --from=build /sojuctl /usr/local/bin/
USER 1000
ENTRYPOINT ["soju"]
