Update Dockerfile

This commit is contained in:
Joshua Schnabel
2020-04-28 21:43:53 +02:00
committed by GitHub
parent 91014fa53f
commit 56a676d075

View File

@ -1,35 +1,68 @@
FROM nodered/node-red:latest-12-minimal FROM node:lts-buster AS base
USER root # Copy scripts
COPY scripts/*.sh /tmp/
#RUN sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories \ # Install tools, create Node-RED app and data dir, add user and set rights
# && apk upgrade --update-cache --available RUN set -ex && \
apt-get update && \
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community/" >> /etc/apk/repositories apt-get intsall --no-cache \
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories bash \
tzdata \
RUN set -ex && apk update \ iputils \
&& apk --no-cache add -u wget build-base sudo libpcap libpcap-dev make perl net-tools bluez-deprecated arp-scan bluez \ curl \
&& rm -rf /var/lib/apt/lists/* nano \
git \
RUN addgroup sudo && addgroup node-red sudo openssl \
openssh-client && \
RUN cat /dev/null > /etc/sudoers \ mkdir -p /usr/src/node-red /data && \
&& echo -e "Set disable_coredump false\n" > /etc/sudo.conf \ deluser --remove-home node && \
&& echo -e "node-red ALL=(ALL) NOPASSWD: ALL\n%sudo ALL=(ALL) NOPASSWD: ALL\n" > /etc/sudoers adduser -h /usr/src/node-red -D -H node-red -u 1000 && \
chown -R node-red:node-red /data && \
RUN cd /tmp/ && wget http://www.mavetju.org/download/dhcpdump-1.8.tar.gz \ chown -R node-red:node-red /usr/src/node-red
&& tar -xzf dhcpdump-1.8.tar.gz \
&& rm dhcpdump-1.8.tar.gz \
&& cd dhcpdump-1.8 \
&& make \
&& mv ./dhcpdump /usr/bin/dhcpdump \
&& chmod +x /usr/bin/dhcpdump \
&& cd /usr/src/node-red \
&& rm -R /tmp/dhcpdump-1.8
RUN apk del build-base libpcap-dev make perl
# Set work directory
WORKDIR /usr/src/node-red 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 intsall --no-cache --virtual buildtools build-base linux-headers udev python && \
npm install --unsafe-perm --no-update-notifier --only=production && \
/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/*
USER node-red 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"]