FROM golang:1.21-alpine as builder

RUN mkdir -p /go/src /go/src/snmp /go/src/config
COPY ./snmp-mqtt.go /go/src
COPY ./snmp/ /go/src/snmp
COPY ./config/ /go/src/config
COPY ./go.mod /go/src
COPY ./go.sum /go/src
WORKDIR /go/src
RUN go mod tidy && go build -a -installsuffix nocgo -o snmp-mqtt github.com/dchote/snmp-mqtt


FROM scratch

ENV SNMP_MQTT_CONF ""

COPY --from=builder /go/src/snmp-mqtt ./
ENTRYPOINT ["./snmp-mqtt"]



