# Compile stage FROM golang:alpine AS build-env ENV CGO_ENABLED 0 ADD . /sub_src # Note that the docker-compose sets the context to the root of the paho.golang module. We do this because otherwise # the subscriber would need to be in its own module and import paho.golang (which makes modifying the example difficult) # When using this for other code you do not need to do this! (just import `github.com/eclipse/paho.golang` in your code!) WORKDIR /sub_src/autopaho/examples/docker/subscriber RUN go build -gcflags "all=-N -l" -o /sub # Final stage FROM scratch COPY --from=build-env /sub / # Run CMD ["/sub"]