Addon for dockerproject

Hi guys,

I’m trying to create an addon for this docker that I found but I cant really get it to work. I’m not 100% sure of what I’m doing when I try ti fix this.

The link above is the link for the docker to a api for sonos that I hade before but now I think I would need some help to make it an addon instead.

Is there anyone who can help me in the right direction?

Thanks!

Did you have any luck with this? I’m interested in doing the same exact thing.

I’ve tried to get this up and running today. However I’ve been running into trouble. The addon builds well, but on startup it becomes obvious the npm install fails on a raspberry. The same dockerfile works well however on another host, so I’m pretty stuck here.

Dockerfile

ARG BUILD_FROM
FROM $BUILD_FROM
ENV LANG C.UTF-8

WORKDIR /data

# Do the installation
RUN apk --no-cache add nodejs nodejs-npm tar curl  && \
  curl -L https://github.com/jishi/node-sonos-http-api/archive/master.tar.gz | tar xz --strip-components=1 -C /data && \
  npm install --production && \
  rm -rf /tmp/* /root/.npm

# Copy data for add-on
COPY run.sh /
RUN chmod a+x /run.sh

# Healthceck (probably not really necessary)
#HEALTHCHECK --interval=1m --timeout=2s \
#CMD curl -LSs http://localhost:5005 || exit 1

# The actual command
CMD [ "/run.sh" ]

run.sh

if [ ! -d /data/static ]; then
mkdir /data/static
fi

if [ ! -d /data/static/clips ]; then
mkdir /data/static/clips
chown -R node:node /data/static
fi

if [ ! -d /data/settings ]; then
mkdir /data/settings
fi
if [ ! -d /data/cache ]; then
mkdir /data/cache
chown -R node:node /data/cache
fi
if [ ! -d /data/presets ]; then
mkdir /data/presets
fi

if [ ! -f /data/presets/example.json ]; then
curl https://raw.githubusercontent.com/jishi/node-sonos-http-api/master/presets/example.json > presets/example.json
fi

if [ ! -f /data/settings/settings.json ]; then
echo {} > settings/settings.json
fi

npm start

config.json

   {
     "name": "Sonos http api",
     "version": "0.2",
     "slug": "sonos_http_api",
     "description": "Serving http api bridge by jishi for sonos as an hassio addon",
     "startup": "before",
     "boot": "auto",
     "options": {},
     "schema": {},
     "ports": {
       "5005/tcp": 5005
     },
     "host_network": true
   }

I ended up getting it working with just the following:

Dockerfile

ARG BUILD_FROM
FROM $BUILD_FROM

WORKDIR /app

RUN apk --no-cache add tar curl nodejs nodejs-npm && \
  curl -L https://github.com/jishi/node-sonos-http-api/archive/master.tar.gz | tar xz -C /app && mv /app/node-sonos-http-api-master/* /app && rm -rf /app/node-sonos-http-api-master && npm install --production

EXPOSE 5005

CMD npm start

config.json

{
  "name": "Sonos HTTP API",
  "version": "1",
  "slug": "node_sonos_http_api",
  "description": "Sonos HTTP API bridge (https://github.com/jishi/node-sonos-http-api)",
  "startup": "before",
  "boot": "auto",
  "options": {},
  "schema": {},
  "ports": { "5005/tcp": 5005 },
  "host_network": "yes"
}

Ok great, this seems to work for me as well. Now I just need to resolve the failing discovery - but that’s probably more of a network issue.

@dasmaeh @markdstjohn are you still using this repo with hassio? Is it straight forward to install and run?