Skip to content

Commit 43a59db

Browse files
authored
Merge pull request #240 from hardillb/dev
Add GH to dev branch
2 parents c3a38eb + 91caf93 commit 43a59db

File tree

3 files changed

+256
-5
lines changed

3 files changed

+256
-5
lines changed

.docker/Dockerfile.alpine

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ ARG OS=alpine
66
FROM ${ARCH}/node:${NODE_VERSION}-${OS} AS base
77
ARG QEMU_ARCH
88

9-
# QEMU - Quick Emulation
10-
COPY tmp/qemu-$QEMU_ARCH-static /usr/bin/qemu-$QEMU_ARCH-static
11-
129
# Copy scripts
1310
COPY .docker/scripts/*.sh /tmp/
1411
COPY .docker/healthcheck.js /
@@ -81,8 +78,7 @@ COPY --from=build /usr/src/node-red/prod_node_modules ./node_modules
8178
# Chown, install devtools & Clean up
8279
RUN chown -R node-red:root /usr/src/node-red && \
8380
/tmp/install_devtools.sh && \
84-
rm -r /tmp/* && \
85-
rm /usr/bin/qemu-$QEMU_ARCH-static
81+
rm -r /tmp/*
8682

8783
USER node-red
8884

.github/workflows/main.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Docker Build
4+
5+
# Controls when the action will run.
6+
on:
7+
release:
8+
types: [published]
9+
10+
11+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
12+
jobs:
13+
# This workflow contains a single job called "build"
14+
build:
15+
env:
16+
# Setting the defaults up front
17+
LATEST_NODE: 14
18+
DEFAULT_IMAGE: nodered/node-red
19+
DEV_IMAGE: nodered/node-red-dev
20+
runs-on: ubuntu-latest
21+
22+
strategy:
23+
matrix:
24+
node: [12, 14]
25+
suffix: ["", "-minimal"]
26+
27+
# Steps represent a sequence of tasks that will be executed as part of the job
28+
steps:
29+
-
30+
name: Checkout
31+
uses: actions/checkout@v2
32+
- name: Show Env
33+
run: env
34+
-
35+
name: Docker Metadata
36+
id: meta
37+
uses: docker/metadata-action@v3
38+
with:
39+
flavor: |
40+
latest=false
41+
suffix=-${{matrix.node}}${{matrix.suffix}}
42+
images: |
43+
${{ env.DEFAULT_IMAGE }}
44+
tags: |
45+
type=ref,event=branch
46+
type=semver,pattern={{version}}
47+
48+
-
49+
name: Setup QEMU
50+
uses: docker/setup-qemu-action@v1
51+
-
52+
name: Setup Docker buildx
53+
uses: docker/setup-buildx-action@v1
54+
- name: Get Date
55+
id: date
56+
run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H:%M:%SZ')"
57+
- name: Get Node-RED Version
58+
id: nrVersion
59+
run: |
60+
TAGS=""
61+
while IFS= read -r TAG;do
62+
if [ -z "$TAGS" ]; then
63+
TAGS=$TAG
64+
else
65+
TAGS="$TAGS,$TAG"
66+
fi
67+
done <<< "${{ steps.meta.outputs.tags }}"
68+
69+
TRAVIS_TAG=$(echo $GITHUB_REF | awk -F '/' '{ print $3}')
70+
if [[ "$TRAVIS_TAG" =~ ^v[0-9\.-]*$ ]]; then
71+
IMAGE=${{ env.DEFAULT_IMAGE }}
72+
PUSH="true"
73+
VERSION=${TRAVIS_TAG:1}
74+
if [ "${{ matrix.node }}" == "${{ env.LATEST_NODE }}" ] && [ "${{ matrix.suffix}}" == "" ]; then
75+
TAGS="$TAGS,$IMAGE:$VERSION,$IMAGE:latest"
76+
fi
77+
else
78+
IMAGE=${{ env.DEV_IMAGE }}
79+
if [[ "$TRAVIS_TAG" == *"dev"* || "$TRAVIS_TAG" == *"beta"* ]]; then
80+
PUSH="true"
81+
else
82+
PUSH="false"
83+
fi
84+
VERSION=${TRAVIS_TAG}
85+
TAGS=$(echo $TAGS | sed 's!${{ env.DEFAULT_IMAGE}}!${{ env.DEV_IMAGE }}!')
86+
if [ "${{ matrix.node }}" == "${{ env.LATEST_NODE }}" ] && [ "${{ matrix.suffix}}" == "" ]; then
87+
TAGS="$TAGS,$IMAGE:$VERSION"
88+
fi
89+
fi
90+
91+
echo $TAGS
92+
93+
echo "::set-output name=tags::$TAGS"
94+
echo "::set-output name=push::$PUSH"
95+
echo "::set-output name=version::$(echo $GITHUB_REF | awk -F '/' '{ print $3}')"
96+
echo "::set-output name=buildVersion::$VERSION"
97+
-
98+
name: Login to DockerHub
99+
uses: docker/login-action@v1
100+
with:
101+
username: ${{ secrets.DOCKERHUB_USERNAME }}
102+
password: ${{ secrets.DOCKERHUB_TOKEN }}
103+
-
104+
name: Build and push
105+
id: build-push
106+
uses: docker/build-push-action@v2
107+
continue-on-error: true
108+
with:
109+
context: .
110+
platforms: linux/amd64, linux/arm64, linux/s390x, linux/arm/v7
111+
push: ${{ steps.nrVersion.outputs.push }}
112+
file: .docker/Dockerfile.alpine
113+
build-args: |
114+
NODE_VERSION=${{ matrix.node }}
115+
BUILD_DATE=${{ steps.date.outputs.date }}
116+
BUILD_VERSION=${{ steps.nrVersion.outputs.buildVersion }}
117+
BUILD_REF=${{ env.GITHUB_SHA }}
118+
NODE_RED_VERSION=v${{ steps.nrVersion.outputs.version }}
119+
TAG_SUFFIX=${{ matrix.suffix }}
120+
121+
tags: ${{ steps.nrVersion.outputs.tags }}
122+
123+
# -
124+
# name: Sign Image
125+
# run: |
126+
# echo "Digest ${{ steps.build-push.outputs.digest }}"
127+
# for TAG in $(echo "${{ steps.nrVersion.outputs.tags }}" | sed "s/,/ /g"); do
128+
# if [[ "$TAG" == "${{ env.DEFAULT_IMAGE }}:latest" ]]; then
129+
# export DOCKER_CONTENT_TRUST=1
130+
# SIGNER_KEY_NAME="8b08f4d8315a5d6443a4f59eaab60a49dacbc105c13d25f167cdb5cc9fa8f9ed.key"
131+
# PATH_KEYS=$HOME/.docker/trust/private
132+
# mkdir -p $PATH_KEYS
133+
# cp .docker/$SIGNER_KEY_NAME $PATH_KEYS
134+
# chmod 600 $PATH_KEYS/$SIGNER_KEY_NAME
135+
# export DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE=${{ secrets.DOCKER_SIGNING_PASSWORD }}
136+
# docker trust key load $PATH_KEYS/$SIGNER_KEY_NAME
137+
# # docker trust sign $TAG
138+
# # docker trust inspect --pretty $TAG
139+
# echo "Siging tag $TAG"
140+
# else
141+
# echo "Not signing $TAG"
142+
# fi
143+
# done

.github/workflows/pr.yaml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Manual Build Test for PRs
4+
5+
# Controls when the action will run.
6+
on:
7+
workflow_dispatch:
8+
9+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
10+
jobs:
11+
# This workflow contains a single job called "build"
12+
build:
13+
env:
14+
# Setting the defaults up front
15+
LATEST_NODE: 14
16+
DEFAULT_IMAGE: nodered/node-red
17+
DEV_IMAGE: nodered/node-red-dev
18+
runs-on: ubuntu-latest
19+
20+
strategy:
21+
matrix:
22+
node: [12, 14]
23+
suffix: ["", "-minimal"]
24+
25+
# Steps represent a sequence of tasks that will be executed as part of the job
26+
steps:
27+
-
28+
name: Checkout
29+
uses: actions/checkout@v2
30+
- name: Show Env
31+
run: env
32+
-
33+
name: Docker Metadata
34+
id: meta
35+
uses: docker/metadata-action@v3
36+
with:
37+
flavor: |
38+
latest=false
39+
suffix=-${{matrix.node}}${{matrix.suffix}}
40+
images: |
41+
${{ env.DEFAULT_IMAGE }}
42+
tags: |
43+
type=ref,event=branch
44+
type=semver,pattern={{version}}
45+
46+
-
47+
name: Setup QEMU
48+
uses: docker/setup-qemu-action@v1
49+
-
50+
name: Setup Docker buildx
51+
uses: docker/setup-buildx-action@v1
52+
- name: Get Date
53+
id: date
54+
run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H:%M:%SZ')"
55+
- name: Get Node-RED Version
56+
id: nrVersion
57+
run: |
58+
TAGS="nodered/node-red-dev:pr-test"
59+
while IFS= read -r TAG;do
60+
if [ -z "$TAGS" ]; then
61+
TAGS=$TAG
62+
else
63+
TAGS="$TAGS,$TAG"
64+
fi
65+
done <<< "${{ steps.meta.outputs.tags }}"
66+
67+
TRAVIS_TAG=$(echo $GITHUB_REF | awk -F '/' '{ print $3}')
68+
if [[ "$TRAVIS_TAG" =~ ^v[0-9\.-]*$ ]]; then
69+
IMAGE=${{ env.DEFAULT_IMAGE }}
70+
VERSION=${TRAVIS_TAG:1}
71+
if [ "${{ matrix.node }}" == "${{ env.LATEST_NODE }}" ] && [ "${{ matrix.suffix}}" == "" ]; then
72+
TAGS="$TAGS,$IMAGE:$VERSION,$IMAGE:latest"
73+
fi
74+
else
75+
IMAGE=${{ env.DEV_IMAGE }}
76+
VERSION=${TRAVIS_TAG}
77+
TAGS=$(echo $TAGS | sed 's!${{ env.DEFAULT_IMAGE}}!${{ env.DEV_IMAGE }}!')
78+
if [ "${{ matrix.node }}" == "${{ env.LATEST_NODE }}" ] && [ "${{ matrix.suffix}}" == "" ]; then
79+
TAGS="$TAGS,$IMAGE:$VERSION"
80+
fi
81+
fi
82+
83+
echo $TAGS
84+
85+
echo "::set-output name=tags::$TAGS"
86+
echo "::set-output name=version::$(echo $GITHUB_REF | awk -F '/' '{ print $3}')"
87+
echo "::set-output name=buildVersion::$VERSION"
88+
# -
89+
# name: Login to DockerHub
90+
# uses: docker/login-action@v1
91+
# with:
92+
# username: ${{ secrets.DOCKERHUB_USERNAME }}
93+
# password: ${{ secrets.DOCKERHUB_TOKEN }}
94+
-
95+
name: Build and push
96+
id: build-push
97+
uses: docker/build-push-action@v2
98+
continue-on-error: true
99+
with:
100+
context: .
101+
platforms: linux/amd64, linux/arm64, linux/s390x, linux/arm/v7
102+
push: false
103+
file: .docker/Dockerfile.alpine
104+
build-args: |
105+
NODE_VERSION=${{ matrix.node }}
106+
BUILD_DATE=${{ steps.date.outputs.date }}
107+
BUILD_VERSION=${{ steps.nrVersion.outputs.buildVersion }}
108+
BUILD_REF=${{ env.GITHUB_SHA }}
109+
NODE_RED_VERSION=v${{ steps.nrVersion.outputs.version }}
110+
TAG_SUFFIX=${{ matrix.suffix }}
111+
112+
tags: ${{ steps.nrVersion.outputs.tags }}

0 commit comments

Comments
 (0)