Create a directory to house your assets
mkdir hello-world && cd hello-world
touch Dockerfile
Let's install the npm package that will bundle our application into a standalone exectuable. This might take a few minutes.
npm install -g enclose
For our node.js server the contents of the Dockerfile would look like the following.
FROM resin/rpi-raspbian
ADD helloworld helloworld
RUN chmod u+x helloworld
...and our helloworld.js file...
echo "console.log('hello world');" >> helloworld.js
Now to bundle it all up!
enclose -o helloworld ./helloworld.js
Now we can build our image...
docker build -t hello-world .
From here we will use a bash script to strip the image of everything but the helloworld
executable
cd
git clone https://github.com/mvanholsteijn/strip-docker-image.git
cd strip-docker-image/bin
strip-docker-image -i hello-world -t mini-hello-world -f helloworld
That should leave us a much smaller image containing only the helloworld
We can run it with...
docker run mini-hello-world ./helloworld
You should see hello world
printto your terminal