diff --git a/nodered/Dockerfile b/nodered/Dockerfile index 072ade8..000a9b3 100644 --- a/nodered/Dockerfile +++ b/nodered/Dockerfile @@ -3,8 +3,16 @@ FROM nodered/node-red:latest-12 USER root RUN apk update && apk upgrade && \ - apk --no-cache add bluez iputils - -RUN apk add dhcpdump --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted - + apk --no-cache add perl libpcap-dev bluez iputils wget + +RUN cd /tmp && \ + wget http://www.mavetju.org/download/dhcpdump-1.8.tar.gz && \ + tar -xzf ./dhcpdump-1.8.tar.gz && \ + cd ./dhcpdump-1.8 && \ + ls && \ + make && \ + install -D dhcpdump /usr/bin/dhcpdump + +WORKDIR /usr/src/node-red + USER node-red diff --git a/nodered/Dockerfile.save b/nodered/Dockerfile.save new file mode 100644 index 0000000..b2b05bc --- /dev/null +++ b/nodered/Dockerfile.save @@ -0,0 +1,89 @@ +FROM node:lts-buster AS base + +# Copy scripts +COPY scripts/*.sh /tmp/ + +RUN mkdir -p /usr/src/node-red /data && \ + deluser --remove-home node && \ + adduser --gecos "" --home /usr/src/node-red --disabled-login --uid 1000 node-red && \ + chown -R node-red:node-red /data && \ + chown -R node-red:node-red /usr/src/node-red && \ + chmod +x /tmp/*.sh + +# Install tools, create Node-RED app and data dir, add user and set rights +RUN set -ex && \ + apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y \ + bash \ + tzdata \ + iputils-ping \ + iputils-arping \ + curl \ + nano \ + git \ + openssl \ + openssh-client + +# Set work directory +WORKDIR /usr/src/node-red + +# package.json contains Node-RED NPM module and node dependencies +COPY package.json . + +#### Stage BUILD ####################################################################################################### +FROM base AS build + +# Install Build tools +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get -y install build-essential linux-headers-$(uname -r) udev python && \ + npm install --unsafe-perm --no-update-notifier --only=production + +RUN /tmp/remove_native_gpio.sh && \ + cp -R node_modules prod_node_modules + +#### Stage RELEASE ##################################################################################################### +FROM base AS RELEASE + +COPY --from=build /usr/src/node-red/prod_node_modules ./node_modules + +# Chown, install devtools & Clean up +RUN chown -R node-red:node-red /usr/src/node-red && \ + /tmp/install_devtools.sh && \ + rm -r /tmp/* + +RUN set -ex \ + && apt-get install -y wget sudo net-tools dhcpdump rfkill bluetooth bluez bluez-tools arp-scan libpcap-dev +RUN addgroup node-red sudo + +RUN cat /dev/null > /etc/sudoers \ + && echo -e "Set disable_coredump false\n" > /etc/sudo.conf \ + && touch /etc/sudoers \ + && echo "node-red ALL=(ALL) NOPASSWD: ALL\n%sudo ALL=(ALL) NOPASSWD: ALL\n" > /etc/sudoers \ + && chmod 0440 /etc/sudoers + +RUN apt-get clean autoclean && \ + apt-get autoremove --yes && \ + rm -rf /var/lib/{apt,dpkg,cache,log}/ + +USER node-red + +# Env variables +ENV NODE_RED_VERSION=$NODE_RED_VERSION \ + NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules \ + FLOWS=flows.json + +# ENV NODE_RED_ENABLE_SAFE_MODE=true # Uncomment to enable safe start mode (flows not running) +# ENV NODE_RED_ENABLE_PROJECTS=true # Uncomment to enable projects option + +# User configuration directory volume +VOLUME ["/data"] + +# Expose the listening port of node-red +EXPOSE 1880 + +# Add a healthcheck (default every 30 secs) +HEALTHCHECK CMD curl http://localhost:1880/ || exit 1 + +ENTRYPOINT ["npm", "start", "--", "--userDir", "/data"]