FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS builder

ARG TARGETOS
ARG TARGETARCH

WORKDIR /app

COPY go.mod ./
COPY main.go ./

RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o debugghttpy .

FROM scratch
LABEL authors="reloia"

WORKDIR /app

COPY --chmod=755 --from=builder /app/debugghttpy .

ENV PORT=3000
ENV DOMAIN="*"

CMD ["./debugghttpy"]