FROM golang:1.26-alpine AS builder

WORKDIR /app

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /usb-relay ./cmd/usb-relay/

FROM alpine:3.21

RUN apk add --no-cache ca-certificates

COPY --from=builder /usb-relay /usr/local/bin/usb-relay

EXPOSE 8443

ENTRYPOINT ["usb-relay"]
CMD ["--port", "8443"]
