From 552ae6d2a66f438fea97541785fd1071514c38d3 Mon Sep 17 00:00:00 2001 From: Mihai Galos Date: Mon, 19 Oct 2020 21:51:38 +0200 Subject: [PATCH 1/3] Dockerize Paper Hacker News --- Dockerfile | 12 ++++++++++++ scripts/main_loop.sh | 14 ++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Dockerfile create mode 100755 scripts/main_loop.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..944ca65 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM node:14.12 + +RUN apt-get update +RUN npm install http-server -g +RUN git clone https://github.com/wolfgang42/paper-hn.git + +WORKDIR /paper-hn +RUN yarn install + +COPY /scripts/main_loop.sh . + +CMD /paper-hn/main_loop.sh diff --git a/scripts/main_loop.sh b/scripts/main_loop.sh new file mode 100755 index 0000000..ba86955 --- /dev/null +++ b/scripts/main_loop.sh @@ -0,0 +1,14 @@ +#! /bin/bash + +cd /paper-hn + +http-server . >http.log 2>&1 & +echo Starting up... > index.html + +while true +do + node --experimental-modules ./bin/generate-html.mjs + sleep 60 + rm cache/hn/*.json +done + From 94472bb95096f07077922b5b5db408ce3c2aadeb Mon Sep 17 00:00:00 2001 From: Mihai Galos Date: Mon, 19 Oct 2020 21:52:41 +0200 Subject: [PATCH 2/3] Set regenerating interval to 300s --- scripts/main_loop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/main_loop.sh b/scripts/main_loop.sh index ba86955..03610c3 100755 --- a/scripts/main_loop.sh +++ b/scripts/main_loop.sh @@ -8,7 +8,7 @@ echo Starting up... > index.html while true do node --experimental-modules ./bin/generate-html.mjs - sleep 60 + sleep 300 rm cache/hn/*.json done From 847a277d43e11eb85a0a7593f81784ed987c0c20 Mon Sep 17 00:00:00 2001 From: Mihai Galos Date: Mon, 19 Oct 2020 22:00:51 +0200 Subject: [PATCH 3/3] Use refresh interval variable defaulting to 300 seconds --- scripts/main_loop.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/main_loop.sh b/scripts/main_loop.sh index 03610c3..3cfd4a1 100755 --- a/scripts/main_loop.sh +++ b/scripts/main_loop.sh @@ -1,5 +1,7 @@ #! /bin/bash + +REFRESH_INTERVAL=${REFRESH_INTERVAL:-300} cd /paper-hn http-server . >http.log 2>&1 & @@ -8,7 +10,7 @@ echo Starting up... > index.html while true do node --experimental-modules ./bin/generate-html.mjs - sleep 300 + sleep $REFRESH_INTERVAL rm cache/hn/*.json done