Accessing /data in Dockerfile still broken?


#1

I was in the process of updating my setup to use the /data folder for persistent storage. I’ve successfully been able to do a local push up until the container is started when I get an error. Here’s the output:

$ sudo resin local push resin.local
* Building..
- Stopping and removing any previous 'homebridge' container
- Uploading build context & starting build...
Step 1/12 : FROM resin/raspberrypi-node:latest
 ---> 9446c42d8082
Step 2/12 : RUN apt-get update && apt-get install -yq     git make python g++ nodejs avahi-daemon avahi-discover libnss-mdns     libavahi-compat-libdnssd-dev &&     apt-get clean && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> 354f683b17e9
Step 3/12 : RUN /etc/init.d/dbus start
 ---> Using cache
 ---> e31105f560d4
Step 4/12 : RUN /etc/init.d/avahi-daemon start
 ---> Using cache
 ---> f3375c2739fa
Step 5/12 : RUN npm install -g --unsafe-perm homebridge
 ---> Using cache
 ---> 37a38a1d2378
Step 6/12 : RUN npm install -g --unsafe-perm homebridge-platform-wemo
 ---> Using cache
 ---> 2e861dd50290
Step 7/12 : RUN npm install -g --unsafe-perm homebridge-nest
 ---> Using cache
 ---> 895fb42e8919
Step 8/12 : WORKDIR /data/homebridge/
 ---> Using cache
 ---> 3dbb4cc16ad3
Step 9/12 : COPY config.json config.json
 ---> Using cache
 ---> 23594a4e2618
Step 10/12 : ENV INITSYSTEM on
 ---> Using cache
 ---> 2d348914d9ea
Step 11/12 : EXPOSE 5353 51826
 ---> Using cache
 ---> fda78f4c833b
Step 12/12 : CMD homebridge --user-storage-path /data/homebridge/
 ---> Using cache
 ---> d8aecfa89169
Successfully built d8aecfa89169
Successfully tagged homebridge:latest
- Creating 'homebridge' container
- Starting 'homebridge' container
rdt push failed. Error: Error while starting container homebridge: Error: (HTTP code 500) server error - invalid character 'c' looking for beginning of value  Error: Error while starting container homebridge: Error: (HTTP code 500) server error - invalid character 'c' looking for beginning of value 
    at /usr/local/lib/node_modules/resin-cli/node_modules/resin-sync/build/docker-utils.js:310:15
    at tryCatcher (/usr/local/lib/node_modules/resin-cli/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/resin-cli/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/usr/local/lib/node_modules/resin-cli/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/usr/local/lib/node_modules/resin-cli/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/usr/local/lib/node_modules/resin-cli/node_modules/bluebird/js/release/promise.js:689:18)
    at Async._drainQueue (/usr/local/lib/node_modules/resin-cli/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/usr/local/lib/node_modules/resin-cli/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/node_modules/resin-cli/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:756:18)
    at tryOnImmediate (timers.js:717:5)
    at processImmediate [as _immediateCallback] (timers.js:697:5)

Here is the Dockerfile:

# base-image for node on any machine using a template variable,
# see more about dockerfile templates here: http://docs.resin.io/deployment/docker-templates/
# and about resin base images here: http://docs.resin.io/runtime/resin-base-images/
# Note the node:slim image doesn't have node-gyp
FROM resin/raspberrypi-node:latest

# Get node source info
#RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

# use apt-get if you need to install dependencies,
# for instance if you need ALSA sound utils, just uncomment the lines below.
RUN apt-get update && apt-get install -yq \
git make python g++ nodejs avahi-daemon avahi-discover libnss-mdns \
libavahi-compat-libdnssd-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN /etc/init.d/dbus start
RUN /etc/init.d/avahi-daemon start

# Install homebridge
RUN npm install -g --unsafe-perm homebridge
RUN npm install -g --unsafe-perm homebridge-platform-wemo
RUN npm install -g --unsafe-perm homebridge-nest

# Copy config over
WORKDIR /data/homebridge/

# Copy
COPY config.json config.json

# Enable systemd init system in container
ENV INITSYSTEM on

# Expose port
EXPOSE 5353 51826

# Exec homebridge
CMD ["homebridge", "--user-storage-path", "/data/homebridge/"]

#4

Looks like the data folder is indeed not accessible. I just copied everything to my home directory and then my CMD is a bash script that copies to the /data/ directory and runs homebridge with the --user-storage-path

The bash script looks like:

#!/bin/bash

echo Makding directory
mkdir -p /data/homebridge/

echo Copying files
cp /root/.homebridge/config.json /data/homebridge/

echo Starting homebridge
homebridge --user-storage-path /data/homebridge/

Jared
jaredwolff.com