-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
786 additions
and
762 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,10 @@ go-auth.h | |
# dependencies | ||
vendor | ||
|
||
# ides and editors | ||
.idea/ | ||
.vscode/ | ||
|
||
Gopkg.lock | ||
|
||
# todo | ||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
#Use debian:stable-slim as a builder and then copy everything. | ||
FROM debian:stable-slim as builder | ||
|
||
#Set mosquitto and plugin versions. | ||
#Change them for your needs. | ||
ENV MOSQUITTO_VERSION=1.6.8 | ||
ENV PLUGIN_VERSION=0.6.1 | ||
ENV GO_VERSION=1.13.8 | ||
|
||
WORKDIR /app | ||
|
||
#Get mosquitto build dependencies. | ||
RUN apt-get update && apt-get install -y libwebsockets8 libwebsockets-dev libc-ares2 libc-ares-dev openssl uuid uuid-dev wget build-essential git | ||
RUN mkdir -p mosquitto/auth mosquitto/conf.d | ||
|
||
RUN wget http:https://mosquitto.org/files/source/mosquitto-${MOSQUITTO_VERSION}.tar.gz | ||
RUN tar xzvf mosquitto-${MOSQUITTO_VERSION}.tar.gz && rm mosquitto-${MOSQUITTO_VERSION}.tar.gz | ||
|
||
#Build mosquitto. | ||
RUN cd mosquitto-${MOSQUITTO_VERSION} && make WITH_WEBSOCKETS=yes && make install && cd .. | ||
|
||
#Get Go. | ||
RUN wget https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz | ||
RUN export PATH=$PATH:/usr/local/go/bin && go version && rm go${GO_VERSION}.linux-amd64.tar.gz | ||
|
||
#Build the plugin from local source | ||
COPY ./ ./ | ||
|
||
#Build the plugin. | ||
RUN export PATH=$PATH:/usr/local/go/bin && export CGO_CFLAGS="-I/usr/local/include -fPIC" && export CGO_LDFLAGS="-shared" && make | ||
|
||
#Start from a new image. | ||
FROM debian:stable-slim | ||
|
||
#Get mosquitto dependencies. | ||
RUN apt-get update && apt-get install -y libwebsockets8 libc-ares2 openssl uuid | ||
|
||
#Setup mosquitto env. | ||
RUN mkdir -p /var/lib/mosquitto /var/log/mosquitto | ||
RUN groupadd mosquitto \ | ||
&& useradd -s /sbin/nologin mosquitto -g mosquitto -d /var/lib/mosquitto \ | ||
&& chown -R mosquitto:mosquitto /var/log/mosquitto/ \ | ||
&& chown -R mosquitto:mosquitto /var/lib/mosquitto/ | ||
|
||
#Copy confs, plugin so and mosquitto binary. | ||
COPY --from=builder /app/mosquitto/ /mosquitto/ | ||
COPY --from=builder /app/go-auth.so /mosquitto/go-auth.so | ||
COPY --from=builder /usr/local/sbin/mosquitto /usr/sbin/mosquitto | ||
|
||
#Uncomment to copy your custom confs (change accordingly) directly when building the image. | ||
#Leave commented if you want to mount a volume for these (see docker-compose.yml). | ||
|
||
# COPY ./docker/conf/mosquitto.conf /etc/mosquitto/mosquitto.conf | ||
# COPY ./docker/conf/conf.d/go-auth.conf /etc/mosquitto/conf.d/go-auth.conf | ||
# COPY ./docker/conf/auth/acls /etc/mosquitto/auth/acls | ||
# COPY ./docker/conf/auth/passwords /etc/mosquitto/auth/passwords | ||
|
||
#Expose tcp and websocket ports as defined at mosquitto.conf (change accordingly). | ||
EXPOSE 1883 1884 | ||
|
||
ENTRYPOINT ["sh", "-c", "/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.