Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Official docker image #15

Closed
gaetancollaud opened this issue Mar 29, 2019 · 9 comments
Closed

Official docker image #15

gaetancollaud opened this issue Mar 29, 2019 · 9 comments

Comments

@gaetancollaud
Copy link

Hello,

Would it be possible to have an official docker image published on dockerhub ?

I will use what I found in #5 for now but it could be great to have an official image instead.

Best regards

@iegomez
Copy link
Owner

iegomez commented Mar 29, 2019

Hi! Absolutely, it sounds like a good idea. I'll try to look into it today if I get the time or next monday. I'll let you know where I get with it.

@gaetancollaud
Copy link
Author

Great !

This is what I got so far (I will update when it works, right now it crash at boot, not sure why..., but I think it's just my mosquitto.conf)

FROM golang as builder

WORKDIR /app

# download
RUN wget https://github.com/iegomez/mosquitto-go-auth/archive/0.2.0.tar.gz \
	&& ls -l \
	&& tar xvf *.tar.gz --strip-components=1 \
	&& rm -Rf *.tar.gz

# add mosquitto dev dependencies
RUN apt-get update && apt-get install -y libmosquitto-dev mosquitto-dev

# build
RUN make

# Extend official eclipse-mosquitto
FROM eclipse-mosquitto
COPY --from=builder /app/go-auth.so /mosquitto

@iegomez
Copy link
Owner

iegomez commented Mar 29, 2019

What's the error you get when it crashes?

@gaetancollaud
Copy link
Author

gaetancollaud commented Mar 29, 2019

That's the issue... I have no error. It just crash

1553875447: mosquitto version 1.5.8 starting
1553875447: Config loaded from /mosquitto/config/mosquitto.conf.
Segmentation fault

My mosquitto.conf:

port 1883

# Auth
auth_plugin /mosquitto/go-auth.so
auth_opt_backends http

auth_opt_http_port 8080
auth_opt_http_host myServer
auth_opt_http_getuser_uri /api/mqtt-getuser
auth_opt_http_superuser_uri /api/mqtt-superuser
auth_opt_http_aclcheck_uri /api/mqtt-aclcheck

# Websocket
listener 9001
protocol websockets

@gaetancollaud
Copy link
Author

gaetancollaud commented Mar 29, 2019

I've just tried with the last source (instead of the release 2.0.0), but same Segmentation fault error :(

Looks related to #14

@iegomez
Copy link
Owner

iegomez commented Mar 29, 2019

It probably is, I still haven't tried Alpine.

If it helps, I just modified a bit an image I had to hack to serve loraserver, lora-app-server, mosquitto and the plugin some time ago. I know almost nothing about docker so it's probably awful, but it works and maybe you can tidy it up to make something useful. The Dockerfile looks like this:

FROM ubuntu:latest
RUN apt-get update && apt-get install -y supervisor libwebsockets8 libwebsockets-dev libc-ares2 libc-ares-dev openssl uuid uuid-dev wget build-essential git
RUN mkdir -p /var/log/supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

RUN mkdir loraserver lora-app-server mosquitto
RUN mkdir mosquitto/auth mosquitto/conf.d
#RUN mkdir .config .config/loraserver .config/lora-app-server

#RUN mkdir /etc/loraserver
#RUN mkdir /etc/lora-app-server

#COPY loraserver /loraserver/loraserver
#COPY lora-app-server lora-app-server/lora-app-server
#COPY configuration/loraserver.toml /etc/loraserver/loraserver.toml
#COPY configuration/lora-app-server.toml /etc/lora-app-server/lora-app-server.toml

RUN wget http://mosquitto.org/files/source/mosquitto-1.5.7.tar.gz
RUN tar xzvf mosquitto-1.5.7.tar.gz

RUN mkdir -p /var/lib/mosquitto
RUN mkdir -p /var/log/mosquitto 

RUN cd mosquitto-1.5.7 && make WITH_WEBSOCKETS=yes && make install && cd ..
RUN groupadd mosquitto
RUN useradd -s /sbin/nologin mosquitto -g mosquitto -d /var/lib/mosquitto
RUN chown -R mosquitto:mosquitto /var/log/mosquitto/
RUN chown -R mosquitto:mosquitto /var/lib/mosquitto/


RUN wget https://dl.google.com/go/go1.12.1.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.12.1.linux-amd64.tar.gz

RUN export PATH=$PATH:/usr/local/go/bin && mkdir -p go/src/github.com/iegomez && cd go/src/github.com/iegomez && git clone https://github.com/iegomez/mosquitto-go-auth.git && cd mosquitto-go-auth/ && export CGO_CFLAGS="-I/usr/local/include -fPIC" && export CGO_LDFLAGS="-shared" && make

COPY mosquitto.conf mosquitto/mosquitto.conf
COPY go-auth.conf mosquitto/conf.d/go-auth.conf
COPY auth/acls mosquitto/auth/acls
COPY auth/passwords mosquitto/auth/passwords

EXPOSE 1883 1884 8080

CMD ["/usr/bin/supervisord"]

I just pushed a repo that includes the conf files: https://github.com/iegomez/mga-docker-test.

As I said, I haven't worked with docker except for that hacky image I made in a hurry, so if you are willing I'd really appreciate any contributions on this. If you aren't able, I'll take a good look at docker documentation and try to assemble a proper image as soon as I get the time.

@gaetancollaud
Copy link
Author

This is a working version, but not optimized at all since it uses ubuntu:latest

FROM golang as builder

WORKDIR /app

# add mosquitto dev dependencies
RUN apt-get update && apt-get install -y libmosquitto-dev mosquitto-dev

# download
RUN wget https://github.com/iegomez/mosquitto-go-auth/archive/0.2.0.tar.gz \
	&& ls -l \
	&& tar xvf *.tar.gz --strip-components=1 \
	&& rm -Rf *.tar.gz


# build
RUN make



FROM ubuntu:latest

RUN apt-get update && \
	apt-get install -y mosquitto

COPY --from=builder /app/go-auth.so /home

ENTRYPOINT ["sh", "-c", "/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf" ]

@iegomez
Copy link
Owner

iegomez commented Apr 1, 2019

Hi, I just came upon this: https://github.com/sgerrand/alpine-pkg-glibc. Haven't tried it myself though.

I also saw this issue, where the last comment mentions some workaround for libc: docker-library/golang#209.

@iegomez
Copy link
Owner

iegomez commented Apr 13, 2019

Hi, @gaetancollaud. Sorry I haven't done anything yet, I couldn't get the time. Were you able to try any of those?

I'll close this for inactivity, I'll let you know if I release an official docker image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants