Skip to content

Commit f38a1e1

Browse files
hardillbknollearyNodeREDBot
authored
Debian build (#346)
* Updates for 3.0.0 - Bump the base Alpine build back to latest - Set NodeJS 16 as default - Drop NodeJS 12 - Add NodeJS 18 * Finish updating README.md * Update default versions in custom build scripts * Add 3.0.0-beta.1 * Merge 3.0.0 work into master (#317) * 2.2.0-beta.1 * Updates for NR 3.0.0 release (#311) * Updates for 3.0.0 - Bump the base Alpine build back to latest - Set NodeJS 16 as default - Drop NodeJS 12 - Add NodeJS 18 * Finish updating README.md * Update default versions in custom build scripts * Add 3.0.0-beta.1 * Bump to 3.0.0-beta.2 * Bump dev to 3.0.0-beta.3 (#314) * Remove Python 2 (#315) * Bump dev to 3.0.0-beta.3 * Remove Python2 from alpine builds * Bump to 3.0.0-beta.4 (#316) * Bump to 2.1.6 * Bump to 2.2.0 * Bump to 2.2.1 * Updates for 3.0.0 - Bump the base Alpine build back to latest - Set NodeJS 16 as default - Drop NodeJS 12 - Add NodeJS 18 * Bump to 3.0.0-beta.4 * Remove new empty line Co-authored-by: knolleary <[email protected]> Co-authored-by: Nick O'Leary <[email protected]> Co-authored-by: knolleary <[email protected]> * Bump to 3.0.0 (#318) Co-authored-by: knolleary <[email protected]> * Add PubkeyAccessKeyTypes settings (#323) * Add PubkeyAccessKeyTypes settings * Add PubkeyAccessKeyTypes settings * Add ssh fix to debian based build * New entrypoint (#324) * Add PubkeyAccessKeyTypes settings * Switch entrypoint to allow NR to run as root if needed This works round npm droping uid when running as root * Bump to 3.0.1 * First pass at fix for #326 (#327) Fix for #326 * Bump to 3.0.2 * Fix NODE_OPTIONS (#334) Thanks to @twocolors for finding this, applying from my id as having problems with easycla * Set python3 to be the default python for npm (#336) * Add stable release tag (#342) * Add a stable tag All 3.0.x will be tagged as nodered/node-red:3.0 All 3.1.x will be tagged as nodered/node-red:3.1 * Calculate Stable version rather than hard code it * Add a debian build --------- Co-authored-by: Nick O'Leary <[email protected]> Co-authored-by: knolleary <[email protected]> Co-authored-by: NodeREDBot <[email protected]>
1 parent 5b064ff commit f38a1e1

File tree

2 files changed

+206
-7
lines changed

2 files changed

+206
-7
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 scripts/*.sh /tmp/
9+
10+
# Install tools, create Node-RED app and data dir, add user and set rights
11+
RUN set -ex && \
12+
apt-get update && apt-get install -y \
13+
bash \
14+
tzdata \
15+
curl \
16+
nano \
17+
wget \
18+
git \
19+
openssl \
20+
openssh-client \
21+
ca-certificates && \
22+
mkdir -p /usr/src/node-red /data && \
23+
deluser --remove-home node && \
24+
# adduser --home /usr/src/node-red --disabled-password --no-create-home node-red --uid 1000 && \
25+
useradd --home-dir /usr/src/node-red --uid 1000 node-red && \
26+
chown -R node-red:root /data && chmod -R g+rwX /data && \
27+
chown -R node-red:root /usr/src/node-red && chmod -R g+rwX /usr/src/node-red
28+
# chown -R node-red:node-red /data && \
29+
# chown -R node-red:node-red /usr/src/node-red
30+
31+
# Set work directory
32+
WORKDIR /usr/src/node-red
33+
34+
# Setup SSH known_hosts file
35+
COPY known_hosts.sh .
36+
RUN ./known_hosts.sh /etc/ssh/ssh_known_hosts && rm /usr/src/node-red/known_hosts.sh
37+
RUN echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> /etc/ssh/ssh_config
38+
39+
# package.json contains Node-RED NPM module and node dependencies
40+
COPY package.json .
41+
COPY flows.json /data
42+
COPY scripts/entrypoint.sh .
43+
44+
#### Stage BUILD #######################################################################################################
45+
FROM base AS build
46+
47+
# Install Build tools
48+
RUN apt-get update && apt-get install -y build-essential python && \
49+
npm install --unsafe-perm --no-update-notifier --no-fund --only=production && \
50+
npm uninstall node-red-node-gpio && \
51+
cp -R node_modules prod_node_modules
52+
53+
#### Stage RELEASE #####################################################################################################
54+
FROM base AS RELEASE
55+
ARG BUILD_DATE
56+
ARG BUILD_VERSION
57+
ARG BUILD_REF
58+
ARG NODE_RED_VERSION
59+
ARG ARCH
60+
ARG TAG_SUFFIX
61+
62+
LABEL org.label-schema.build-date=${BUILD_DATE} \
63+
org.label-schema.docker.dockerfile=".docker/Dockerfile.debian" \
64+
org.label-schema.license="Apache-2.0" \
65+
org.label-schema.name="Node-RED" \
66+
org.label-schema.version=${BUILD_VERSION} \
67+
org.label-schema.description="Low-code programming for event-driven applications." \
68+
org.label-schema.url="https://nodered.org" \
69+
org.label-schema.vcs-ref=${BUILD_REF} \
70+
org.label-schema.vcs-type="Git" \
71+
org.label-schema.vcs-url="https://github.com/node-red/node-red-docker" \
72+
org.label-schema.arch=${ARCH} \
73+
authors="Dave Conway-Jones, Nick O'Leary, James Thomas, Raymond Mouthaan"
74+
75+
COPY --from=build /usr/src/node-red/prod_node_modules ./node_modules
76+
77+
# Chown, install devtools & Clean up
78+
RUN chown -R node-red:root /usr/src/node-red && \
79+
apt-get update && apt-get install -y build-essential python-dev python3 && \
80+
rm -r /tmp/*
81+
82+
RUN npm config set cache /data/.npm --global
83+
RUN npm config set python `which python3` --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 curl http://localhost:1880/ || exit 1
101+
102+
ENTRYPOINT ["./entrypoint.sh"]

.github/workflows/main.yml

Lines changed: 104 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ on:
1010

1111
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1212
jobs:
13-
# This workflow contains a single job called "build"
14-
build:
13+
# This workflow contains a 2 jobs called "alpine" and "debian"
14+
alpine:
1515
env:
1616
# Setting the defaults up front
1717
LATEST_NODE: 16
@@ -28,7 +28,7 @@ jobs:
2828
steps:
2929
-
3030
name: Checkout
31-
uses: actions/checkout@v2
31+
uses: actions/checkout@v3
3232
- name: Show Env
3333
run: env
3434
-
@@ -97,10 +97,15 @@ jobs:
9797
9898
echo $TAGS
9999
100-
echo "::set-output name=tags::$TAGS"
101-
echo "::set-output name=push::$PUSH"
102-
echo "::set-output name=version::$(echo $GITHUB_REF | awk -F '/' '{ print $3}')"
103-
echo "::set-output name=buildVersion::$VERSION"
100+
echo "{tags}={$TAGS}" >> $GITHUB_OUTPUT
101+
echo "{push}={$PUSH}" >> $GITHUB_OUTPUT
102+
echo "{version}={$(echo $GITHUB_REF | awk -F '/' '{ print $3}')}" >> $GITHUB_OUTPUT
103+
echo "{buildVersion}={$VERSION}" >> $GITHUB_OUTPUT
104+
105+
# echo "::set-output name=tags::$TAGS"
106+
# echo "::set-output name=push::$PUSH"
107+
# echo "::set-output name=version::$(echo $GITHUB_REF | awk -F '/' '{ print $3}')"
108+
# echo "::set-output name=buildVersion::$VERSION"
104109
-
105110
name: Login to DockerHub
106111
uses: docker/login-action@v1
@@ -127,6 +132,96 @@ jobs:
127132
128133
tags: ${{ steps.nrVersion.outputs.tags }}
129134

135+
debian:
136+
env:
137+
# Setting the defaults up front
138+
LATEST_NODE: 16
139+
DEFAULT_IMAGE: nodered/node-red
140+
DEV_IMAGE: nodered/node-red-dev
141+
runs-on: ubuntu-latest
142+
143+
steps:
144+
- name: Checkout
145+
uses: actions/checkout@v3
146+
- name: Setup QEMU
147+
uses: docker/setup-qemu-action@v1
148+
- name: Setup Docker buildx
149+
uses: docker/setup-buildx-action@v1
150+
- name: Login to DockerHub
151+
uses: docker/login-action@v1
152+
with:
153+
username: ${{ secrets.DOCKERHUB_USERNAME }}
154+
password: ${{ secrets.DOCKERHUB_TOKEN }}
155+
- name: Get Date
156+
id: date
157+
run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H:%M:%SZ')"
158+
- name: Docker Metadata
159+
id: meta
160+
uses: docker/metadata-action@v3
161+
with:
162+
flavor: |
163+
latest=false
164+
images: |
165+
${{ env.DEFAULT_IMAGE }}
166+
tags: |
167+
type=ref,event=branch
168+
type=semver,pattern={{version}}
169+
170+
- name: Get Node-RED Version
171+
id: nrVersion
172+
run: |
173+
TAGS=""
174+
175+
echo Original tags ${{ steps.meta.outputs.tags }}
176+
177+
TRAVIS_TAG=$(echo $GITHUB_REF | awk -F '/' '{ print $3}')
178+
if [[ "$TRAVIS_TAG" =~ ^v[0-9\.-]*$ ]]; then
179+
# release build
180+
IMAGE=${{ env.DEFAULT_IMAGE }}
181+
PUSH="true"
182+
VERSION=${TRAVIS_TAG:1}
183+
STABLE_VERSION=`echo ${VERSION} | sed -r 's/^([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)$/\1.\2/'`
184+
185+
TAGS="$IMAGE:latest-debian,$IMAGE:$VERSION-debian,$IMAGE:STABLE_VERSION-debian"
186+
187+
else
188+
IMAGE=${{ env.DEV_IMAGE }}
189+
if [[ "$TRAVIS_TAG" == *"dev"* || "$TRAVIS_TAG" == *"beta"* ]]; then
190+
# beta build
191+
PUSH="true"
192+
else
193+
PUSH="false"
194+
fi
195+
VERSION=${TRAVIS_TAG}
196+
197+
TAGS="$IMAGE:$VERSION-debian"
198+
199+
fi
200+
201+
echo $TAGS
202+
echo "{tags}={$TAGS}" >> $GITHUB_OUTPUT
203+
echo "{push}={$PUSH}" >> $GITHUB_OUTPUT
204+
echo "{version}={$(echo $GITHUB_REF | awk -F '/' '{ print $3}')}" >> $GITHUB_OUTPUT
205+
echo "{buildVersion}={$VERSION}" >> $GITHUB_OUTPUT
206+
207+
- name: Build and push
208+
id: build-push
209+
uses: docker/build-push-action@v2
210+
continue-on-error: true
211+
with:
212+
context: .
213+
platforms: linux/amd64, linux/arm64, linux/s390x, linux/arm/v7, linux/arm/v6
214+
file: .docker/Dockerfile.debian
215+
push: ${{ steps.nrVersion.outputs.push }}
216+
build-args: |
217+
NODE_VERSION=${{ env.LATEST_NODE }}
218+
BUILD_DATE=${{ steps.date.outputs.date }}
219+
BUILD_REF=${{ env.GITHUB.SHA }}
220+
TAG_SUFFIX=-debian
221+
NODE_RED_VERSION=${{ steps.nrVersion.outputs.version }}
222+
BUILD_VERSION=${{ steps.nrVersion.outputs.buildVersion }}
223+
tags: ${{ steps.nrVersion.outputs.tags }}
224+
130225
# -
131226
# name: Sign Image
132227
# run: |
@@ -148,3 +243,5 @@ jobs:
148243
# echo "Not signing $TAG"
149244
# fi
150245
# done
246+
247+

0 commit comments

Comments
 (0)