forked from node-red/node-red-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
294987f
commit 67c2af3
Showing
5 changed files
with
176 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
ARG ARCH | ||
ARG NODE_VERSION | ||
ARG OS | ||
ARG NODE_RED_VERSION | ||
|
||
FROM ${ARCH}/node:${NODE_VERSION}-${OS} | ||
|
||
# Basic build-time metadata as defined at http://label-schema.org | ||
ARG BUILD_DATE | ||
ARG NODE_RED_VERSION | ||
ARG ARCH | ||
ARG PYTHON_VERSION | ||
ARG OS | ||
|
||
LABEL org.label-schema.build-date=${BUILD_DATE} \ | ||
org.label-schema.docker.dockerfile="Dockerfile-slim.custom" \ | ||
org.label-schema.license="GNU" \ | ||
org.label-schema.name="Node-RED" \ | ||
org.label-schema.version=${NODE_RED_VERSION} \ | ||
org.label-schema.description="Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways." \ | ||
org.label-schema.url="https://nodered.org" \ | ||
org.label-schema.vcs-type="Git" \ | ||
org.label-schema.arch=${ARCH} \ | ||
maintainer="Your Name <your email>" | ||
|
||
# Copy scripts | ||
COPY ../.docker/scripts/* /tmp/ | ||
|
||
# Install tools, create Node-RED app and data dir, add user and set rights | ||
RUN set -ex && \ | ||
apt-get update && apt-get install -y --no-install-recommends \ | ||
iputils-ping \ | ||
curl \ | ||
nano \ | ||
git \ | ||
openssh-client && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
mkdir -p /usr/src/node-red /data && \ | ||
useradd --home-dir /usr/src/node-red --no-create-home node-red && \ | ||
chown -R node-red:node-red /data && \ | ||
chown -R node-red:node-red /usr/src/node-red | ||
|
||
# Install Python 2 & gpio library (Python 2.7 will reach the end of its life on January 1st, 2020!) | ||
RUN chmod u+x /tmp/python2_gpio.sh && /tmp/python2_gpio.sh | ||
|
||
# Install Python 3 & gpio library | ||
RUN chmod u+x /tmp/python3_gpio.sh && /tmp/python3_gpio.sh | ||
|
||
# Set work directory | ||
WORKDIR /usr/src/node-red | ||
|
||
# Run as node-red user | ||
USER node-red | ||
|
||
# package.json contains Node-RED NPM module and node dependencies | ||
COPY package.json /usr/src/node-red/ | ||
RUN npm install | ||
|
||
# Replace Python 2.7 with 3.6 in 36-rpi-gpio.js or remove Node-RED build-in rpi-gpio for non arm32v6 | ||
USER root | ||
RUN chmod u+x /tmp/python_fix.sh && /tmp/python_fix.sh | ||
|
||
# Cleanup tmp | ||
RUN rm /tmp/* | ||
|
||
# Return as node-red user | ||
USER node-red | ||
|
||
# Env variables | ||
ENV NODE_RED_VERSION=$NODE_RED_VERSION | ||
ENV FLOWS=flows.json | ||
ENV NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules | ||
|
||
# User configuration directory volume | ||
VOLUME ["/data"] | ||
|
||
# Expose the listening port of node-red | ||
EXPOSE 1880 | ||
|
||
HEALTHCHECK --interval=5s --timeout=3s --retries=3 \ | ||
CMD curl -f http://localhost:1880 || exit 1 | ||
|
||
ENTRYPOINT ["npm", "start", "--", "--userDir", "/data"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Build your own Docker image | ||
|
||
The docker-custom directory contains files you need to build your own images. | ||
|
||
The steps to take to build your own images are: | ||
|
||
1) **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 | ||
|
||
2) **docker-make.sh** | ||
|
||
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` : the linux distro you like to use (alpine or buster-slim) | ||
- `--build-arg BUILD_DATE="$(date +"%Y-%m-%dT%H:%M:%SZ")"` : don't change this | ||
- `--build-arg PYTHON_VERSION=0` : add Python to your image (0=no Python, 2=Python 2.x, 3=Python 3.x) | ||
- `--file Dockerfile-alpine.custom` : Dockerfile to use to build your image (Dockerfile-alpine.custom or Dockerfile-slim.custom) | ||
- `--tag mynodered:node-red-custom-build` : set the image name and tag | ||
|
||
3) **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 it by the following command: | ||
|
||
``` | ||
$ docker run -it -p1880:1880 mynodered:node-red-custom-build | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
export NODE_RED_VERSION=$(grep -Eo "\"node-red\": \"(\w*.\w*.\w*)" package.json | cut -d\" -f4) | ||
sed "s/\(version\": \"\).*\(\"\)/\1$NODE_RED_VERSION\"/g" package.json > tmpfile && mv tmpfile package.json | ||
|
||
echo "### Update version ######################################################" | ||
echo "node-red version: ${NODE_RED_VERSION}" | ||
echo "#########################################################################" | ||
|
||
docker build --no-cache \ | ||
--build-arg ARCH=amd64 \ | ||
--build-arg NODE_VERSION=12 \ | ||
--build-arg NODE_RED_VERSION=${NODE_RED_VERSION} \ | ||
--build-arg OS=alpine \ | ||
--build-arg BUILD_DATE="$(date +"%Y-%m-%dT%H:%M:%SZ")" \ | ||
--build-arg PYTHON_VERSION=0 \ | ||
--file Dockerfile-alpine.custom \ | ||
--tag testing:node-red-build . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "node-red-docker", | ||
"version": "1.0.0", | ||
"description": "A visual tool for wiring the Internet of Things", | ||
"homepage": "http://nodered.org", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/node-red/node-red-docker.git" | ||
}, | ||
"main": "node_modules/node-red/red/red.js", | ||
"scripts": { | ||
"start": "node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Dave Conway-Jones" | ||
}, | ||
{ | ||
"name": "Nick O'Leary" | ||
}, | ||
{ | ||
"name": "James Thomas" | ||
}, | ||
{ | ||
"name": "Raymond Mouthaan" | ||
} | ||
], | ||
"dependencies": { | ||
"node-red": "0.20.7" | ||
}, | ||
"engines": { | ||
"node": "8.*.*" | ||
} | ||
} |