FROM golang:latest as builder

WORKDIR /app

COPY go.mod go.sum ./
COPY . .

RUN go mod download && \
    CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main ./pkg/spamasaurusrex

FROM scratch

WORKDIR /app

COPY --from=builder /app/main .

EXPOSE 8080

CMD ["./main"]