Skip to content

Commit

Permalink
combine functions for easier maintenance.
Browse files Browse the repository at this point in the history
  • Loading branch information
RaymondMouthaan committed Aug 24, 2019
1 parent 71184ff commit 5efe3ce
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 28 deletions.
8 changes: 4 additions & 4 deletions .docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ RUN set -ex && \
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 gpio library
RUN chmod u+x /tmp/install_python_gpio.sh && /tmp/install_python_gpio.sh

# Install Python 3 & gpio library
RUN chmod u+x /tmp/python3_gpio.sh && /tmp/python3_gpio.sh
# Install Devtools
#RUN chmod u+x /tmp/install_devtools.sh && /tmp/install_devtools.sh

# Set work directory
WORKDIR /usr/src/node-red
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ set -ex
if [[ ${PYTHON_VERSION} != "0" ]]; then
echo "Fixing 36-rpi-gpio.js for Python"
sed -i 's/python2.7/python/g' node_modules/\@node-red/nodes/core/hardware/36-rpi-gpio.js

# Create symlink for python libs
if [[ ${OS} == "alpine" ]]; then
ln -s /usr/lib/python$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))') /usr/lib/python
else
ln -s /usr/lib/python3 /usr/lib/python
fi
ln -s /usr/lib/python$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))') /usr/lib/python
fi

# Remove Node-Red build-in rpi-gpio when python is not installed or for non arm arch
Expand Down
24 changes: 12 additions & 12 deletions .docker/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ docker_manifest_list() {

if [[ ${1} == "-10" ]]; then
echo "DOCKER MANIFEST: Create and Push docker manifest list TESTING."
docker_manifest_list_testing_or_latest_rpi_python2 ${1} "testing"
docker_manifest_list_testing_or_latest_rpi_python3 ${1} "testing"
docker_manifest_list_testing_or_latest_rpi ${1} "testing"
docker_manifest_list_testing_or_latest_python2 ${1} "testing"
docker_manifest_list_testing_or_latest_python3 ${1} "testing"
docker_manifest_list_testing_or_latest ${1} "testing"
docker_manifest_list_testing_or_latest_rpi_python2 "" "testing"
docker_manifest_list_testing_or_latest_rpi_python3 "" "testing"
docker_manifest_list_testing_or_latest_rpi "" "testing"
docker_manifest_list_testing_or_latest_python2 "" "testing"
docker_manifest_list_testing_or_latest_python3 "" "testing"
docker_manifest_list_testing_or_latest "" "testing"
fi
;;
*)
Expand All @@ -144,12 +144,12 @@ docker_manifest_list() {

if [[ ${1} == "-10" ]]; then
echo "DOCKER MANIFEST: Create and Push docker manifest list LATEST."
docker_manifest_list_testing_or_latest_rpi_python2 ${1} "latest"
docker_manifest_list_testing_or_latest_rpi_python3 ${1} "latest"
docker_manifest_list_testing_or_latest_rpi ${1} "latest"
docker_manifest_list_testing_or_latest_python2 ${1} "latest"
docker_manifest_list_testing_or_latest_python3 ${1} "latest"
docker_manifest_list_testing_or_latest ${1} "latest"
docker_manifest_list_testing_or_latest_rpi_python2 "" "latest"
docker_manifest_list_testing_or_latest_rpi_python3 "" "latest"
docker_manifest_list_testing_or_latest_rpi "" "latest"
docker_manifest_list_testing_or_latest_python2 "" "latest"
docker_manifest_list_testing_or_latest_python3 "" "latest"
docker_manifest_list_testing_or_latest "" "latest"
fi
;;
esac
Expand Down
9 changes: 9 additions & 0 deletions .docker/scripts/install_devtools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -ex

# Install Python3 and pigpio library for arm
if [[ ${DEVTOOLS} == "1" ]]; then
echo "Installing Devtools"

apk --no-cache add --virtual builds-deps build-base
fi
35 changes: 35 additions & 0 deletions .docker/scripts/install_python_gpio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
set -ex

# Install Python2
if [[ ${PYTHON_VERSION} == "2" ]]; then
echo "Installing Python 2"
apk add --no-cache python
fi

# Install Python3
if [[ ${PYTHON_VERSION} == "3" ]]; then
echo "Installing Python 3"
apk add --no-cache python3
echo "Fixing Python 3 symlink"
ln -s /usr/bin/python3 /usr/bin/python
fi

# Install rpigpio library for arm
if [[ ${PYTHON_VERSION} != "0" ]]; then
if [[ ${ARCH} == "arm32v6" ]] || [[ ${ARCH} == "arm32v7" ]]; then
echo "Installing py-rpigpio"
apk add py-rpigpio

echo "Fixing 36-rpi-gpio.js for Python"
sed -i 's/python2.7/python/g' node_modules/\@node-red/nodes/core/hardware/36-rpi-gpio.js
# Create symlink for python libs
ln -s /usr/lib/python$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))') /usr/lib/python
fi
fi

# Remove Node-Red build-in rpi-gpio when python is not installed or for non arm arch
if [[ ${PYTHON_VERSION} == "0" ]] || ! { [[ ${ARCH} == "arm32v6" ]] || [[ ${ARCH} == "arm32v7" ]]; }; then
echo "Removing Node-RED build-in rpi-gpio"
rm -r node_modules/\@node-red/nodes/core/hardware/*
fi
19 changes: 13 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,45 @@ env:
matrix:
### Node JS 12 ####################################################################################################
# No Python Images
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=x86_64 ARCH=amd64 PYTHON_VERSION=0
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=x86_64 ARCH=amd64 PYTHON_VERSION=0
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=arm ARCH=arm32v6 PYTHON_VERSION=0
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=arm ARCH=arm32v7 PYTHON_VERSION=0
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=aarch64 ARCH=arm64v8 PYTHON_VERSION=0

# Python 2 Images
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=x86_64 ARCH=amd64 PYTHON_VERSION=2
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=x86_64 ARCH=amd64 PYTHON_VERSION=2
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=arm ARCH=arm32v6 PYTHON_VERSION=2
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=arm ARCH=arm32v7 PYTHON_VERSION=2
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=aarch64 ARCH=arm64v8 PYTHON_VERSION=2

# Python 3 Images
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=x86_64 ARCH=amd64 PYTHON_VERSION=3
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=x86_64 ARCH=amd64 PYTHON_VERSION=3
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=arm ARCH=arm32v6 PYTHON_VERSION=3
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=arm ARCH=arm32v7 PYTHON_VERSION=3
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=aarch64 ARCH=arm64v8 PYTHON_VERSION=3

# Devtools Images
# Python 3 Images
# - DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=x86_64 ARCH=amd64 PYTHON_VERSION=3 DEVTOOLS=1
# - DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=arm ARCH=arm32v6 PYTHON_VERSION=3 DEVTOOLS=1
# - DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=arm ARCH=arm32v7 PYTHON_VERSION=3 DEVTOOLS=1
# - DOCKER_FILE=Dockerfile.alpine NODE_VERSION=12 OS=alpine QEMU_ARCH=aarch64 ARCH=arm64v8 PYTHON_VERSION=3 DEVTOOLS=1

### Node JS 10 ####################################################################################################
# No Python Images
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=x86_64 ARCH=amd64 PYTHON_VERSION=0
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=x86_64 ARCH=amd64 PYTHON_VERSION=0
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=arm ARCH=arm32v6 PYTHON_VERSION=0
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=arm ARCH=arm32v7 PYTHON_VERSION=0
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=aarch64 ARCH=arm64v8 PYTHON_VERSION=0

# Python 2 Images
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=x86_64 ARCH=amd64 PYTHON_VERSION=2
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=x86_64 ARCH=amd64 PYTHON_VERSION=2
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=arm ARCH=arm32v6 PYTHON_VERSION=2
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=arm ARCH=arm32v7 PYTHON_VERSION=2
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=aarch64 ARCH=arm64v8 PYTHON_VERSION=2

# Python 3 Images
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=x86_64 ARCH=amd64 PYTHON_VERSION=3
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=x86_64 ARCH=amd64 PYTHON_VERSION=3
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=arm ARCH=arm32v6 PYTHON_VERSION=3
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=arm ARCH=arm32v7 PYTHON_VERSION=3
- DOCKER_FILE=Dockerfile.alpine NODE_VERSION=10 OS=alpine QEMU_ARCH=aarch64 ARCH=arm64v8 PYTHON_VERSION=3
Expand Down

0 comments on commit 5efe3ce

Please sign in to comment.