diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0be0c3a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# get latest 1.15.8 golang +FROM golang:1.15.8 + +# create and set workingfolder +WORKDIR /go/src/ + +# download dependencies +RUN go get -v -u -d github.com/gin-gonic/gin github.com/lib/pq github.com/eclipse/paho.mqtt.golang github.com/go-sql-driver/mysql + +# copy all sourcecode +COPY src/ . + +# compile the program +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . + + +# get latest alpine container +FROM alpine:latest + +# add ca-certificates +RUN apk --no-cache add ca-certificates + +# create workdir +WORKDIR /root/ + +# copy binary from first container +COPY --from=0 /go/src/app . + +# run application +CMD ["./app"]