Search code examples
herokubuildpack

heroku buildpack for installing libmosquitto


I'm trying to create a small buildpack for a Heroku app that uses a MQTT broker. To establish a communication channel with the broker I use the mosquitto gem, which itself require me to install a package on the system and build it.

The gem has pretty simple instructions:

sudo apt-get update
sudo apt-get install pkg-config cmake openssl libc-ares-dev

wget http://mosquitto.org/files/source/mosquitto-1.3.1.tar.gz
tar xzf mosquitto-1.3.1.tar.gz
cd mosquitto-1.3.1
cmake .
sudo make install

I need a buildpack that would do just that on a Heroku cedar app. I gave it a shot heroku-buildpack-mosquitto, but I failed and I get an error. I'm not a shell expert and I have no clue what I'm doing.

I use the following .buildpack, together with heroku-buildpack-multi:

https://github.com/ddollar/heroku-buildpack-apt.git
https://github.com/rolandjitsu/heroku-buildpack-mosquitto.git
https://github.com/heroku/heroku-buildpack-ruby.git

And the Aptfile for heroku-buildpack-apt:

pkg-config
cmake
openssl
libc-ares-dev

I get the following error:

/tmp/buildpack_23cdb652-73cc-461b-b70f-ec3f386ebee1/bin/compile: line 44: /tmp/buildpack5JP7B/bin/detect: No such file or directory

I would appreciate any help since I am not capable of figuring this out myself :)


Solution

  • You are missing bin/detect script in your buildpack. This is the script that confirms whether the code you pushed is, in our case, a Ruby project. So you probably want to try this:

    #!/usr/bin/env bash
    # bin/detect <build-dir>
    
    if [ -f $1/Gemfile ]; then
      echo "Ruby" && exit 0
    else
      echo "no" && exit 1
    fi