# dockerfiles/Dockerfile.hermes-chat-router
FROM --platform=$BUILDPLATFORM golang:1.24-alpine@sha256:8bee1901f1e530bfb4a7850aa7a479d17ae3a18beb6e09064ed54cfd245b7191 AS build

ARG TARGETOS
ARG TARGETARCH

WORKDIR /src
COPY services/hermes/router/ ./

RUN GO111MODULE=off CGO_ENABLED=0 go test . \
    && GOOS=${TARGETOS} GOARCH=${TARGETARCH} GO111MODULE=off CGO_ENABLED=0 go build \
      -trimpath \
      -ldflags="-s -w" \
      -o /out/chat-router .

FROM scratch

COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build --chown=10000:10000 /out/chat-router /chat-router

USER 10000:10000
EXPOSE 8080
ENTRYPOINT ["/chat-router"]
