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