Skip to content

Commit

Permalink
add nodered
Browse files Browse the repository at this point in the history
  • Loading branch information
up9cloud committed Jul 3, 2024
1 parent 36ed4a9 commit 1c3c31a
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 80 deletions.
86 changes: 53 additions & 33 deletions Dockerfile-all.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,70 @@ ${PARTIAL_0}

FROM sstc/headful-chromium:ubuntu-24
RUN set -ex; \
apt update; \
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
tini \
iputils-ping \
dnsutils \
rsync \
curl \
jq \
; \
# In the mean time, install all popular scripting languages
# curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -; \
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
# nodejs \
# npm \
php \
ruby \
lua5.4 \
; \
bash --version; \
perl --version; \
# python2 --version; \
python3 --version; \
node -v; \
npm -v; \
php -v; \
ruby -v; \
lua -v; \
apt clean; \
rm -rf /var/lib/apt/lists/*
apt update; \
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
tini \
iputils-ping \
dnsutils \
rsync \
curl \
jq \
; \
# In the mean time, install all popular scripting languages
# curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -; \
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
# nodejs \
# npm \
php \
ruby \
lua5.4 \
; \
bash --version; \
perl --version; \
# python2 --version; \
python3 --version; \
node -v; \
npm -v; \
php -v; \
ruby -v; \
lua -v; \
apt clean; \
rm -rf /var/lib/apt/lists/*

# https://npmtrends.com/axios-vs-got-vs-node-fetch-vs-request-vs-superagent
RUN set -e; \
npm -g install \
node-fetch
npm -g install \
node-fetch

WORKDIR /gocron2
COPY --from=builder /tmp/gocron2 /gocron2/gocron2
COPY --from=builder /tmp/gocron2-node /gocron2/gocron2-node
COPY --from=builder /tmp/certstrap /gocron2/certstrap
COPY run-all.sh /gocron2/run-all.sh
COPY init-cert.sh /gocron2/init-cert.sh

VOLUME [ "/gocron2/conf", "/gocron2/log", "/gocron2/out", "/app" ]
# https://github.com/node-red/node-red-docker/blob/master/docker-custom/Dockerfile.debian
RUN set -ex; \
apt update; \
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
bash \
tzdata \
curl \
nano \
wget \
git \
openssl \
openssh-client \
ca-certificates \
;

RUN set -e; \
npm i -g --unsafe-perm --no-update-notifier --no-fund --only=production \
node-red

WORKDIR /app
VOLUME [ "/gocron2/conf", "/gocron2/log", "/gocron2/out", "/nodered", "/app" ]
EXPOSE 5920
EXPOSE 5921
EXPOSE 1880
ENTRYPOINT ["tini", "--"]
CMD ["/gocron2/run-all.sh"]
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,41 @@ docker run -d --name gocron2-node \
> Multiple nodes with certs
```bash
# Create certs for main node
# Create certs for main node (we mount conf/ to out/, because certs will output to out/)
docker run --rm \
-v /path/to/out:/gocron2/out \
-v /path/to/conf:/gocron2/out \
sstc/gocron2 ./init-cert.sh

# Create certs for worker nodes
docker run --rm \
-v /path/to/out:/gocron2/out \
-v /path/to/conf:/gocron2/out \
sstc/gocron2 ./init-cert.sh 1.2.3.4

# Configure main node: add those to /path/to/conf/app.ini
# enable_tls = true
# ca_file = /gocron2/out/Root_CA.crt
# cert_file = /gocron2/out/127.0.0.1.crt
# key_file = /gocron2/out/127.0.0.1.key
# ca_file = /gocron2/conf/Root_CA.crt
# cert_file = /gocron2/conf/127.0.0.1.crt
# key_file = /gocron2/conf/127.0.0.1.key

# Up main node
docker run -d --name gocron2 \
-v /path/to/conf:/gocron2/conf \
-v /path/to/log:/gocron2/log \
-v /path/to/out:/gocron2/out \
-p 5920:5920 \
sstc/gocron2:server

# Copy cert files in /path/to/out for the worker nodes
# Copy cert files in /path/to/conf for the worker nodes

# Up all worker nodes
docker run -d --name gocron2-node \
-v /path/to/out:/gocron2/out \
-v /path/to/conf:/gocron2/conf \
-v /path/to/my-task-scripts:/app \
-p 5921:5921 \
sstc/gocron2 gocron2-node -allow-root \
-enable-tls \
-ca-file /gocron2/out/Root_CA.crt \
-cert-file /gocron2/out/1.2.3.4.crt \
-key-file /gocron2/out/1.2.3.4.key
-ca-file /gocron2/conf/Root_CA.crt \
-cert-file /gocron2/conf/1.2.3.4.crt \
-key-file /gocron2/conf/1.2.3.4.key

# Open 127.0.0.1:5920 to install
```
86 changes: 53 additions & 33 deletions all/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,50 +21,70 @@ RUN set -ex; \

FROM sstc/headful-chromium:ubuntu-24
RUN set -ex; \
apt update; \
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
tini \
iputils-ping \
dnsutils \
rsync \
curl \
jq \
; \
# In the mean time, install all popular scripting languages
# curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -; \
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
# nodejs \
# npm \
php \
ruby \
lua5.4 \
; \
bash --version; \
perl --version; \
# python2 --version; \
python3 --version; \
node -v; \
npm -v; \
php -v; \
ruby -v; \
lua -v; \
apt clean; \
rm -rf /var/lib/apt/lists/*
apt update; \
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
tini \
iputils-ping \
dnsutils \
rsync \
curl \
jq \
; \
# In the mean time, install all popular scripting languages
# curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -; \
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
# nodejs \
# npm \
php \
ruby \
lua5.4 \
; \
bash --version; \
perl --version; \
# python2 --version; \
python3 --version; \
node -v; \
npm -v; \
php -v; \
ruby -v; \
lua -v; \
apt clean; \
rm -rf /var/lib/apt/lists/*

# https://npmtrends.com/axios-vs-got-vs-node-fetch-vs-request-vs-superagent
RUN set -e; \
npm -g install \
node-fetch
npm -g install \
node-fetch

WORKDIR /gocron2
COPY --from=builder /tmp/gocron2 /gocron2/gocron2
COPY --from=builder /tmp/gocron2-node /gocron2/gocron2-node
COPY --from=builder /tmp/certstrap /gocron2/certstrap
COPY run-all.sh /gocron2/run-all.sh
COPY init-cert.sh /gocron2/init-cert.sh

VOLUME [ "/gocron2/conf", "/gocron2/log", "/gocron2/out", "/app" ]
# https://github.com/node-red/node-red-docker/blob/master/docker-custom/Dockerfile.debian
RUN set -ex; \
apt update; \
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
bash \
tzdata \
curl \
nano \
wget \
git \
openssl \
openssh-client \
ca-certificates \
;

RUN set -e; \
npm i -g --unsafe-perm --no-update-notifier --no-fund --only=production \
node-red

WORKDIR /app
VOLUME [ "/gocron2/conf", "/gocron2/log", "/gocron2/out", "/nodered", "/app" ]
EXPOSE 5920
EXPOSE 5921
EXPOSE 1880
ENTRYPOINT ["tini", "--"]
CMD ["/gocron2/run-all.sh"]
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#/bin/bash

docker build -t gocron2 -f all/Dockerfile .
5 changes: 3 additions & 2 deletions run-all.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

./gocron2 web &
./gocron2-node -allow-root &
/gocron2/gocron2 web &
/gocron2/gocron2-node -allow-root &
npx -g node-red --userDir /nodered &
wait -n
exit $?

0 comments on commit 1c3c31a

Please sign in to comment.