Skip to content

Commit 6b66973

Browse files
authored
Merge pull request #385 from node-red/dev
Dev
2 parents 7ebcdc3 + 89d5977 commit 6b66973

File tree

4 files changed

+222
-13
lines changed

4 files changed

+222
-13
lines changed

.docker/Dockerfile.debian

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
ARG NODE_VERSION=16
2+
ARG OS=buster-slim
3+
4+
#### Stage BASE ########################################################################################################
5+
FROM node:${NODE_VERSION}-${OS} AS base
6+
7+
# Copy scripts
8+
COPY .docker/scripts/*.sh /tmp/
9+
COPY .docker/healthcheck.js /
10+
11+
# Install tools, create Node-RED app and data dir, add user and set rights
12+
RUN set -ex && \
13+
apt-get update && apt-get install -y \
14+
bash \
15+
tzdata \
16+
curl \
17+
nano \
18+
wget \
19+
git \
20+
openssl \
21+
openssh-client \
22+
ca-certificates && \
23+
mkdir -p /usr/src/node-red /data && \
24+
deluser --remove-home node && \
25+
# adduser --home /usr/src/node-red --disabled-password --no-create-home node-red --uid 1000 && \
26+
useradd --home-dir /usr/src/node-red --uid 1000 node-red && \
27+
chown -R node-red:root /data && chmod -R g+rwX /data && \
28+
chown -R node-red:root /usr/src/node-red && chmod -R g+rwX /usr/src/node-red
29+
# chown -R node-red:node-red /data && \
30+
# chown -R node-red:node-red /usr/src/node-red
31+
32+
# Set work directory
33+
WORKDIR /usr/src/node-red
34+
35+
# Setup SSH known_hosts file
36+
COPY .docker/known_hosts.sh .
37+
RUN ./known_hosts.sh /etc/ssh/ssh_known_hosts && rm /usr/src/node-red/known_hosts.sh
38+
RUN echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> /etc/ssh/ssh_config
39+
40+
# package.json contains Node-RED NPM module and node dependencies
41+
COPY package.json .
42+
COPY flows.json /data
43+
COPY .docker/scripts/entrypoint.sh .
44+
45+
#### Stage BUILD #######################################################################################################
46+
FROM base AS build
47+
48+
# Install Build tools
49+
RUN apt-get update && apt-get install -y build-essential python && \
50+
npm install --unsafe-perm --no-update-notifier --no-fund --only=production && \
51+
npm uninstall node-red-node-gpio && \
52+
cp -R node_modules prod_node_modules
53+
54+
#### Stage RELEASE #####################################################################################################
55+
FROM base AS RELEASE
56+
ARG BUILD_DATE
57+
ARG BUILD_VERSION
58+
ARG BUILD_REF
59+
ARG NODE_RED_VERSION
60+
ARG ARCH
61+
ARG TAG_SUFFIX
62+
63+
LABEL org.label-schema.build-date=${BUILD_DATE} \
64+
org.label-schema.docker.dockerfile=".docker/Dockerfile.debian" \
65+
org.label-schema.license="Apache-2.0" \
66+
org.label-schema.name="Node-RED" \
67+
org.label-schema.version=${BUILD_VERSION} \
68+
org.label-schema.description="Low-code programming for event-driven applications." \
69+
org.label-schema.url="https://nodered.org" \
70+
org.label-schema.vcs-ref=${BUILD_REF} \
71+
org.label-schema.vcs-type="Git" \
72+
org.label-schema.vcs-url="https://github.com/node-red/node-red-docker" \
73+
org.label-schema.arch=${ARCH} \
74+
authors="Dave Conway-Jones, Nick O'Leary, James Thomas, Raymond Mouthaan"
75+
76+
COPY --from=build /usr/src/node-red/prod_node_modules ./node_modules
77+
78+
# Chown, install devtools & Clean up
79+
RUN chown -R node-red:root /usr/src/node-red && \
80+
apt-get update && apt-get install -y build-essential python-dev python3 && \
81+
rm -r /tmp/*
82+
83+
RUN npm config set cache /data/.npm --global
84+
85+
USER node-red
86+
87+
# Env variables
88+
ENV NODE_RED_VERSION=$NODE_RED_VERSION \
89+
NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules \
90+
PATH=/usr/src/node-red/node_modules/.bin:${PATH} \
91+
FLOWS=flows.json
92+
93+
# ENV NODE_RED_ENABLE_SAFE_MODE=true # Uncomment to enable safe start mode (flows not running)
94+
# ENV NODE_RED_ENABLE_PROJECTS=true # Uncomment to enable projects option
95+
96+
# Expose the listening port of node-red
97+
EXPOSE 1880
98+
99+
# Add a healthcheck (default every 30 secs)
100+
HEALTHCHECK CMD node /healthcheck.js
101+
102+
ENTRYPOINT ["./entrypoint.sh"]

.github/workflows/main.yml

Lines changed: 116 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ on:
1616

1717
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1818
jobs:
19-
# This workflow contains a single job called "build"
20-
build:
19+
# This workflow contains a 2 jobs called "alpine" and "debian"
20+
alpine:
2121
env:
2222
# Setting the defaults up front
2323
LATEST_NODE: 16
@@ -34,7 +34,7 @@ jobs:
3434
steps:
3535
-
3636
name: Checkout
37-
uses: actions/checkout@v2
37+
uses: actions/checkout@v3
3838
- name: Show Env
3939
run: env
4040
-
@@ -89,10 +89,11 @@ jobs:
8989
fi
9090
9191
echo "TRAVIS_TAG = $TRAVIS_TAG"
92-
92+
93+
TRAVIS_TAG=$(echo $GITHUB_REF | awk -F '/' '{ print $3}')
9394
if [[ "$TRAVIS_TAG" =~ ^v[0-9\.-]*$ ]]; then
9495
IMAGE=${{ env.DEFAULT_IMAGE }}
95-
PUSH="true"
96+
PUSH=true
9697
VERSION=${TRAVIS_TAG:1}
9798
STABLE_VERSION=`echo ${VERSION} | sed -r 's/^([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)$/\1.\2/'`
9899
@@ -107,9 +108,9 @@ jobs:
107108
else
108109
IMAGE=${{ env.DEV_IMAGE }}
109110
if [[ "$TRAVIS_TAG" == *"dev"* || "$TRAVIS_TAG" == *"beta"* ]]; then
110-
PUSH="true"
111+
PUSH=true
111112
else
112-
PUSH="false"
113+
PUSH=false
113114
fi
114115
VERSION=${TRAVIS_TAG}
115116
TAGS=$(echo $TAGS | sed 's!${{ env.DEFAULT_IMAGE}}!${{ env.DEV_IMAGE }}!')
@@ -119,11 +120,17 @@ jobs:
119120
fi
120121
121122
echo $TAGS
123+
echo "tags=$TAGS" >> $GITHUB_OUTPUT
124+
echo "push=$PUSH" >> $GITHUB_OUTPUT
125+
echo "version=$TRAVIS_TAG" >> $GITHUB_OUTPUT
126+
echo "buildVersion=$VERSION" >> $GITHUB_OUTPUT
127+
128+
cat $GITHUB_OUTPUT
122129
123-
echo "::set-output name=tags::$TAGS"
124-
echo "::set-output name=push::$PUSH"
125-
echo "::set-output name=version::$TRAVIS_TAG"
126-
echo "::set-output name=buildVersion::$VERSION"
130+
# echo "::set-output name=tags::$TAGS"
131+
# echo "::set-output name=push::$PUSH"
132+
# echo "::set-output name=version::$TRAVIS_TAG"
133+
# echo "::set-output name=buildVersion::$VERSION"
127134
-
128135
name: Login to DockerHub
129136
uses: docker/login-action@v1
@@ -150,6 +157,102 @@ jobs:
150157
151158
tags: ${{ steps.nrVersion.outputs.tags }}
152159

160+
debian:
161+
env:
162+
# Setting the defaults up front
163+
LATEST_NODE: 16
164+
DEFAULT_IMAGE: nodered/node-red
165+
DEV_IMAGE: nodered/node-red-dev
166+
runs-on: ubuntu-latest
167+
168+
steps:
169+
- name: Checkout
170+
uses: actions/checkout@v3
171+
- name: Setup QEMU
172+
uses: docker/setup-qemu-action@v1
173+
- name: Setup Docker buildx
174+
uses: docker/setup-buildx-action@v1
175+
- name: Login to DockerHub
176+
uses: docker/login-action@v1
177+
with:
178+
username: ${{ secrets.DOCKERHUB_USERNAME }}
179+
password: ${{ secrets.DOCKERHUB_TOKEN }}
180+
- name: Get Date
181+
id: date
182+
run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H:%M:%SZ')"
183+
- name: Docker Metadata
184+
id: meta
185+
uses: docker/metadata-action@v4
186+
with:
187+
flavor: |
188+
latest=false
189+
images: |
190+
${{ env.DEFAULT_IMAGE }}
191+
tags: |
192+
type=ref,event=branch
193+
type=semver,pattern={{version}}
194+
195+
- name: Get Node-RED Version
196+
id: nrVersion
197+
run: |
198+
TAGS=""
199+
200+
echo Original tags ${{ steps.meta.outputs.tags }}
201+
202+
if [[ ! -z "${{ github.event.inputs.version }}" ]]; then
203+
TRAVIS_TAG=${{ github.event.inputs.version }}
204+
else
205+
TRAVIS_TAG=$(echo $GITHUB_REF | awk -F '/' '{ print $3}')
206+
fi
207+
208+
if [[ "$TRAVIS_TAG" =~ ^v[0-9\.-]*$ ]]; then
209+
# release build
210+
IMAGE=${{ env.DEFAULT_IMAGE }}
211+
PUSH=true
212+
VERSION=${TRAVIS_TAG:1}
213+
STABLE_VERSION=`echo ${VERSION} | sed -r 's/^([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)$/\1.\2/'`
214+
215+
TAGS="$IMAGE:latest-debian,$IMAGE:$VERSION-debian,$IMAGE:STABLE_VERSION-debian"
216+
217+
else
218+
IMAGE=${{ env.DEV_IMAGE }}
219+
if [[ "$TRAVIS_TAG" == *"dev"* || "$TRAVIS_TAG" == *"beta"* ]]; then
220+
# beta build
221+
PUSH=true
222+
else
223+
PUSH=false
224+
fi
225+
VERSION=${TRAVIS_TAG}
226+
227+
TAGS="$IMAGE:$VERSION-debian"
228+
229+
fi
230+
231+
echo $TAGS
232+
echo "tags=$TAGS" >> $GITHUB_OUTPUT
233+
echo "push=$PUSH" >> $GITHUB_OUTPUT
234+
echo "version=$TRAVIS_TAG" >> $GITHUB_OUTPUT
235+
echo "buildVersion=$VERSION" >> $GITHUB_OUTPUT
236+
237+
cat $GITHUB_OUTPUT
238+
239+
- name: Build and push
240+
id: build-push
241+
uses: docker/build-push-action@v2
242+
with:
243+
context: .
244+
platforms: linux/amd64, linux/arm64, linux/arm/v7
245+
file: .docker/Dockerfile.debian
246+
push: ${{ steps.nrVersion.outputs.push }}
247+
build-args: |
248+
NODE_VERSION=${{ env.LATEST_NODE }}
249+
BUILD_DATE=${{ steps.date.outputs.date }}
250+
BUILD_REF=${{ env.GITHUB.SHA }}
251+
TAG_SUFFIX=-debian
252+
NODE_RED_VERSION=${{ steps.nrVersion.outputs.version }}
253+
BUILD_VERSION=${{ steps.nrVersion.outputs.buildVersion }}
254+
tags: ${{ steps.nrVersion.outputs.tags }}
255+
153256
# -
154257
# name: Sign Image
155258
# run: |
@@ -171,3 +274,5 @@ jobs:
171274
# echo "Not signing $TAG"
172275
# fi
173276
# done
277+
278+

docker-custom/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
"node-red": "3.0.2"
3333
},
3434
"engines": {
35-
"node": ">=12"
35+
"node": ">=14"
3636
}
3737
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "node-red-docker",
3+
"version": "3.1.0-beta.4",
34
"version": "3.0.2",
45
"description": "Low-code programming for event-driven applications",
56
"homepage": "http://nodered.org",
@@ -29,9 +30,10 @@
2930
}
3031
],
3132
"dependencies": {
33+
"node-red": "3.1.0-beta.4"
3234
"node-red": "3.0.2"
3335
},
3436
"engines": {
35-
"node": ">=12"
37+
"node": ">=14"
3638
}
3739
}

0 commit comments

Comments
 (0)