tarantool / mqtt

Tarantool MQTT client
tarantool.org
BSD 2-Clause "Simplified" License
39 stars 10 forks source link

mqtt is not usable after installing into the official tarantool:1.x-centos7 Docker image #41

Closed akudiyar closed 2 years ago

akudiyar commented 4 years ago

Steps to reproduce:

  1. Deploy a container based on the tarantool/tarantool:1.x-centos7 image:

docker-compose.yml:

version: '3'

services:
  tarantool:
    container_name: tarantool
    build:
      context: .
      dockerfile: Dockerfile.tarantool
    command: tarantool /opt/tarantool/app.lua
    volumes:
      - ./app.lua:/opt/tarantool/app.lua
    ports:
      - '3301:3301'
      - '3333:3333'
      - '8080:80'
    network_mode: host

Dockerfile.tarantool:

FROM tarantool/tarantool:1.x-centos7

WORKDIR /

RUN yum -y install git cmake make gcc-c++ openssl openssl-devel
RUN tarantoolctl rocks install mqtt

WORKDIR /opt/tarantool

app.lua:

mqtt = require('mqtt')
  1. Container fails to start up:
a.kuzin@a:~/tmp/amq$ docker-compose up
Starting tarantool ... done
Attaching to tarantool
tarantool    | /.rocks/share/tarantool/mqtt/init.lua:32: module 'mqtt.driver' not found:
tarantool    |  no field package.preload['mqtt.driver']
tarantool    |  no file './mqtt/driver.lua'
tarantool    |  no file './mqtt/driver/init.lua'
tarantool    |  no file './mqtt/driver.so'
tarantool    |  no file '/opt/tarantool/.rocks/share/tarantool/mqtt/driver.lua'
tarantool    |  no file '/opt/tarantool/.rocks/share/tarantool/mqtt/driver/init.lua'
tarantool    |  no file '/opt/.rocks/share/tarantool/mqtt/driver.lua'
tarantool    |  no file '/opt/.rocks/share/tarantool/mqtt/driver/init.lua'
tarantool    |  no file '/.rocks/share/tarantool/mqtt/driver.lua'
tarantool    |  no 
tarantool exited with code 1

The reason is that the mqtt driver is not linked with mosquitto:

[root@caca61ec4fc2 tarantool]# ldd /.rocks/lib/tarantool/mqtt/driver.so
    linux-vdso.so.1 =>  (0x00007ffef4f02000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f1269ee1000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f1269cc5000)
    libmosquitto.so.1 => not found
    libssl.so.10 => /lib64/libssl.so.10 (0x00007f1269a53000)
    libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f12695f0000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f12693e8000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f126901a000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f126a2eb000)
    libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f1268dcd000)
    libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f1268ae4000)
    libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f12688e0000)
    libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f12686ad000)
    libz.so.1 => /lib64/libz.so.1 (0x00007f1268497000)
    libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f1268287000)
    libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f1268083000)
    libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f1267e6a000)
    libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f1267c43000)
    libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f12679e1000)
[root@caca61ec4fc2 tarantool]# ls -l /usr/lib64/ | grep libmosq
[root@caca61ec4fc2 tarantool]# ls -l /usr/local/lib64/ | grep libmosq
lrwxrwxrwx 1 root root      19 Apr 24 16:54 libmosquittopp.so -> libmosquittopp.so.1
lrwxrwxrwx 1 root root      23 Apr 24 16:54 libmosquittopp.so.1 -> libmosquittopp.so.1.6.2
-rwxr-xr-x 1 root root   65072 Apr 24 16:53 libmosquittopp.so.1.6.2
lrwxrwxrwx 1 root root      17 Apr 24 16:54 libmosquitto.so -> libmosquitto.so.1
lrwxrwxrwx 1 root root      21 Apr 24 16:54 libmosquitto.so.1 -> libmosquitto.so.1.6.2
-rwxr-xr-x 1 root root 1153624 Apr 24 16:53 libmosquitto.so.1.6.2

We need to fix the cmake script for correct installing of libmosquitto or correct linking of the driver.

vr009 commented 2 years ago

@akudiyar I don't see installing mosquitto library in your steps. That seems to be a reason why mqtt builds without it. Anyway with the new mqtt release this library will be built and linked statically if you installing the module with luarocks. So you won't have to install it manually.

Totktonada commented 2 years ago

The main problem is fixed in #39. The plan is the following:

Totktonada commented 2 years ago

I overlooked that mqtt was installed in a child image, not our CentOS 7 based image. Anyway, we'll update the module in Alpine images, where it is present and has an old version.