Skip to content

Building Custom Image

Dave Conway-Jones edited this page Oct 17, 2019 · 3 revisions

Build your own Docker image

The docker-custom directory contains files you need to build your own fully custom images.

If you just want to add some nodes or containerise a simple project you may want to use a Quick Custom Image.

The follow steps describe in short which steps to take to build your own images.

  1. git clone

    Clone the Node-RED Docker project from github

    git clone https://github.com/node-red/node-red-docker.git

    Change dir to docker-custom

    cd node-red-docker/docker-custom
  2. package.json

    • Change the node-red version in package.json (from the docker-custom directory) to the version you require
    • Add optionally packages you require
  3. docker-make.sh

    The docker-make.sh is a helper script to build a custom Node-RED docker image.

    Change the build arguments as needed:

    - `--build-arg ARCH=amd64` : architecture your are building for (arm32v6, arm32v7, arm64v8, amd64)
    - `--build-arg NODE_VERSION=10` : NodeJS version you like to use
    - `--build-arg NODE_RED_VERSION=${NODE_RED_VERSION}` : don't change this, ${NODE_RED_VERSION} gets populated from package.json
    - `--build-arg OS=alpine` : don't change this (alpine)
    - `--build-arg BUILD_DATE="$(date +"%Y-%m-%dT%H:%M:%SZ")"` : don't change this
    - `--build-arg TAG_SUFFIX=default` : to build the default or minimal image
    - `--file Dockerfile.custom` : Dockerfile to use to build your image.
    - `--tag testing:node-red-build` : set the image name and tag
    
  4. Run docker-make.sh

    Run docker-make.sh

    $ ./docker-make.sh

    This starts building your custom image and might take a while depending on the system you are running on.

    When building is done you can run the custom image by the following command:

    $ docker run -it -p1880:1880 testing:node-red-build

    With the following command you can verify your docker image:

    $ docker inspect testing:node-red-build

Advanced Configuration

The Dockerfile.custom file can be modified as required. To add more applications the scripts/install_devtools.sh can be modified as needed.

Use Case - Installing extra Python packages

Assume you want to build your own custom image with the following Python packages pre-installed:

  • adafruit-circuitpython-neopixel
  • adafruit-circuitpython-motorkit
  • above packages require python3-dev
  1. Modify scripts/install_devtools.sh as follows:

    #!/bin/bash
    set -ex
    
    # Installing Devtools
    if [[ ${TAG_SUFFIX} != "minimal" ]]; then
     echo "Installing devtools"
     apk add --no-cache --virtual devtools build-base linux-headers udev python python3 python3-dev
     pip3 install --upgrade pip
     pip3 install adafruit-circuitpython-neopixel
     pip3 install adafruit-circuitpython-motorkit
    else
     echo "Skip installing devtools"
    fi
    
  2. Run docker-make.sh

    $ ./docker-make.sh