-
-
Notifications
You must be signed in to change notification settings - Fork 168
/
Dockerfile
89 lines (72 loc) · 3.29 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
FROM golang:1.15.3-alpine3.12 as builder
LABEL stage=intermediate
#compile linux only
ENV \
GOOS=linux \
VOLANTMQ_WORK_DIR=/usr/lib/volantmq \
VOLANTMQ_BUILD_FLAGS="-i" \
VOLANTMQ_PLUGINS_DIR=/usr/lib/volantmq/plugins \
GO111MODULE=on
RUN mkdir -p $VOLANTMQ_WORK_DIR/bin
RUN mkdir -p $VOLANTMQ_WORK_DIR/conf
RUN mkdir -p $VOLANTMQ_PLUGINS_DIR
# git required by govvv
# gcc&g++ for building plugins
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh gcc g++
# Create environment directory
ENV PATH $VOLANTMQ_WORK_DIR/bin:$PATH
# build server
RUN \
GO111MODULE=off go get -v github.com/VolantMQ/volantmq/cmd/volantmq \
&& cd $GOPATH/src/github.com/VolantMQ/volantmq/cmd/volantmq \
&& GO111MODULE=on go mod tidy \
&& go get github.com/troian/govvv \
&& govvv build $VOLANTMQ_BUILD_FLAGS -o $VOLANTMQ_WORK_DIR/bin/volantmq
RUN cp $GOPATH/src/github.com/VolantMQ/volantmq/tools/print_version.sh /bin
# build debug plugins
RUN \
GO111MODULE=off go get gitlab.com/VolantMQ/vlplugin/debug \
&& cd $GOPATH/src/gitlab.com/VolantMQ/vlplugin/debug \
&& GO111MODULE=on go mod tidy \
&& go build $VOLANTMQ_BUILD_FLAGS -buildmode=plugin -ldflags "-X main.version=$(print_version.sh)" -o $VOLANTMQ_WORK_DIR/plugins/debug.so
# build health plugins
RUN \
GO111MODULE=off go get gitlab.com/VolantMQ/vlplugin/health \
&& cd $GOPATH/src/gitlab.com/VolantMQ/vlplugin/health \
&& GO111MODULE=on go mod tidy \
&& go build $VOLANTMQ_BUILD_FLAGS -buildmode=plugin -ldflags "-X main.version=$(print_version.sh)" -o $VOLANTMQ_WORK_DIR/plugins/health.so
# build metrics plugins
RUN \
GO111MODULE=off go get gitlab.com/VolantMQ/vlplugin/monitoring/prometheus \
&& cd $GOPATH/src/gitlab.com/VolantMQ/monitoring/prometheus \
&& GO111MODULE=on go mod tidy \
&& go build $VOLANTMQ_BUILD_FLAGS -buildmode=plugin -ldflags "-X main.version=$(print_version.sh)" -o $VOLANTMQ_WORK_DIR/plugins/prometheus.so
RUN \
GO111MODULE=off go get gitlab.com/VolantMQ/vlplugin/monitoring/systree \
&& cd $GOPATH/src/gitlab.com/VolantMQ/monitoring/systree \
&& GO111MODULE=on go mod tidy \
&& go build $VOLANTMQ_BUILD_FLAGS -buildmode=plugin -ldflags "-X main.version=$(print_version.sh)" -o $VOLANTMQ_WORK_DIR/plugins/systree.so
#build persistence plugins
RUN \
GO111MODULE=off go get gitlab.com/VolantMQ/vlplugin/persistence/bbolt \
&& cd $GOPATH/src/gitlab.com/VolantMQ/vlplugin/persistence/bbolt \
&& GO111MODULE=on go mod tidy \
&& cd plugin \
&& go build $VOLANTMQ_BUILD_FLAGS -buildmode=plugin -ldflags "-X main.version=$(print_version.sh)" -o $VOLANTMQ_WORK_DIR/plugins/persistence_bbolt.so
#build auth plugins
RUN \
GO111MODULE=off go get gitlab.com/VolantMQ/vlplugin/auth/http \
&& cd $GOPATH/src/gitlab.com/VolantMQ/vlplugin/auth/http \
&& GO111MODULE=on go mod tidy \
&& go build $VOLANTMQ_BUILD_FLAGS -buildmode=plugin -ldflags "-X main.version=$(print_version.sh)" -o $VOLANTMQ_WORK_DIR/plugins/auth_http.so
FROM alpine
ENV \
VOLANTMQ_WORK_DIR=/usr/lib/volantmq
COPY --from=builder $VOLANTMQ_WORK_DIR $VOLANTMQ_WORK_DIR
# Create environment directory
ENV PATH $VOLANTMQ_WORK_DIR/bin:$PATH
ENV VOLANTMQ_PLUGINS_DIR=$VOLANTMQ_WORK_DIR/plugins
# default config uses mqtt:1883
EXPOSE 1883
CMD ["volantmq"]