From 233dcdc1d14f1f0098ad65eb91464ac7d3300d4b Mon Sep 17 00:00:00 2001 From: alfonsomunozpomer Date: Tue, 29 Dec 2020 01:53:01 +0000 Subject: [PATCH 1/5] =?UTF-8?q?Don=E2=80=99t=20apply=20colour=20to=20headi?= =?UTF-8?q?ng=20spaces=20in=20the=20channel=20logo=20lines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #24 --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 870c7a0..e06cf03 100644 --- a/index.js +++ b/index.js @@ -171,10 +171,10 @@ class Site { default: return [ siteJSBlue('███████ ██ ████████ ███████  ██ ███████'), - siteJSBlue(' ██      ██    ██    ██       ██ ██     '), - siteJSBlue(' ███████ ██  ██  █████  ██ ███████'), - siteJSBlue('      ██ ██  ██  ██     ██ ██      ██'), - siteJSBlue(' ███████ ██  ██  ███████ ██  █████  ███████'), + ` ${siteJSBlue('██      ██    ██    ██       ██ ██     ')}`, + ` ${siteJSBlue('███████ ██  ██  █████  ██ ███████')}`, + ` ${siteJSBlue('     ██ ██  ██  ██     ██ ██      ██')}`, + ` ${siteJSBlue('███████ ██  ██  ███████ ██  █████  ███████')}`, '\n' ] } From 19432526b0fd33dd36d25760cd60ff9ff46c8859 Mon Sep 17 00:00:00 2001 From: alfonsomunozpomer Date: Tue, 29 Dec 2020 02:17:06 +0000 Subject: [PATCH 2/5] =?UTF-8?q?Add=20serve=20command=20flag=20that=20doesn?= =?UTF-8?q?=E2=80=99t=20disable=20privileged=20ports=20for=20Docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/commands/serve.js | 6 +++++- bin/lib/ensure.js | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/commands/serve.js b/bin/commands/serve.js index fe06e0e..893f99b 100644 --- a/bin/commands/serve.js +++ b/bin/commands/serve.js @@ -20,6 +20,7 @@ const SYNC_TO = 'sync-to' const SYNC_FROM = 'sync-from' const LIVE_SYNC = 'live-sync' const SYNC_FOLDER_AND_CONTENTS = 'sync-folder-and-contents' +const DOCKER = 'docker' // This will only show errors in the access log (HTTP response codes 4xx and 5xx). const ACCESS_LOG_ERRORS_ONLY = 'access-log-errors-only' @@ -145,6 +146,9 @@ function serve (args) { const syncRequested = args.named[SYNC_TO] !== undefined const liveSync = args.named[LIVE_SYNC] + // Is Site.js running in a Docker container? + const docker = args.named[DOCKER] + // // Handle initial sync setup-related tasks. // @@ -186,7 +190,7 @@ function serve (args) { // Ensure privileged ports are disabled on Linux machines. // For details, see: https://source.small-tech.org/site.js/app/-/issues/169 - ensure.privilegedPortsAreDisabled() + ensure.privilegedPortsAreDisabled(docker) // Start a server and also sync if requested. tcpPortUsed.check(port) diff --git a/bin/lib/ensure.js b/bin/lib/ensure.js index 03d4455..1f30ef8 100644 --- a/bin/lib/ensure.js +++ b/bin/lib/ensure.js @@ -122,8 +122,8 @@ class Ensure { // execute, we carry it out every time. // // For more details, see: https://source.small-tech.org/site.js/app/-/issues/169 - privilegedPortsAreDisabled () { - if (os.platform() === 'linux') { + privilegedPortsAreDisabled (docker) { + if (os.platform() === 'linux' && !docker) { try { Site.logAppNameAndVersion() From 57d3ee4fa41144baa722c96d6fa9fc912a0b1236 Mon Sep 17 00:00:00 2001 From: alfonsomunozpomer Date: Tue, 29 Dec 2020 02:17:06 +0000 Subject: [PATCH 3/5] =?UTF-8?q?Add=20serve=20command=20flag=20that=20doesn?= =?UTF-8?q?=E2=80=99t=20disable=20privileged=20ports=20for=20Docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/commands/serve.js | 6 +++++- bin/lib/Help.js | 3 +++ bin/lib/ensure.js | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/commands/serve.js b/bin/commands/serve.js index fe06e0e..893f99b 100644 --- a/bin/commands/serve.js +++ b/bin/commands/serve.js @@ -20,6 +20,7 @@ const SYNC_TO = 'sync-to' const SYNC_FROM = 'sync-from' const LIVE_SYNC = 'live-sync' const SYNC_FOLDER_AND_CONTENTS = 'sync-folder-and-contents' +const DOCKER = 'docker' // This will only show errors in the access log (HTTP response codes 4xx and 5xx). const ACCESS_LOG_ERRORS_ONLY = 'access-log-errors-only' @@ -145,6 +146,9 @@ function serve (args) { const syncRequested = args.named[SYNC_TO] !== undefined const liveSync = args.named[LIVE_SYNC] + // Is Site.js running in a Docker container? + const docker = args.named[DOCKER] + // // Handle initial sync setup-related tasks. // @@ -186,7 +190,7 @@ function serve (args) { // Ensure privileged ports are disabled on Linux machines. // For details, see: https://source.small-tech.org/site.js/app/-/issues/169 - ensure.privilegedPortsAreDisabled() + ensure.privilegedPortsAreDisabled(docker) // Start a server and also sync if requested. tcpPortUsed.check(port) diff --git a/bin/lib/Help.js b/bin/lib/Help.js index dfd505c..2278e94 100644 --- a/bin/lib/Help.js +++ b/bin/lib/Help.js @@ -82,6 +82,8 @@ class Help { const optionAccessLogErrorsOnly = option('access-log-errors-only') const optionAccessLogDisable = option('access-log-disable') + const optionDocker = option('docker') + // Black right-pointing triangle (U+25B6) // (There are several similar unicode gylphs but this is the one that works well across // Linux, macOS, and Windows). @@ -150,6 +152,7 @@ class Help { ${optionSyncFrom}\t\t\t\tThe folder to sync from. ${optionLiveSync}\t\t\t\tWatch for changes and live sync them to a remote server. ${optionSyncFolderAndContents}\t\tSync local folder and contents (default is to sync the folder’s contents only). + ${optionDocker}\t\t\t\tSet when running in a Docker container (does not disable privileged ports). ${ this.systemdExists ? `For ${commandEnable} command: diff --git a/bin/lib/ensure.js b/bin/lib/ensure.js index 03d4455..1f30ef8 100644 --- a/bin/lib/ensure.js +++ b/bin/lib/ensure.js @@ -122,8 +122,8 @@ class Ensure { // execute, we carry it out every time. // // For more details, see: https://source.small-tech.org/site.js/app/-/issues/169 - privilegedPortsAreDisabled () { - if (os.platform() === 'linux') { + privilegedPortsAreDisabled (docker) { + if (os.platform() === 'linux' && !docker) { try { Site.logAppNameAndVersion() From 4c986608bc1f44d1a802f9a8e1b2f9a759afb100 Mon Sep 17 00:00:00 2001 From: alfonsomunozpomer Date: Tue, 29 Dec 2020 02:37:55 +0000 Subject: [PATCH 4/5] Add Dockerfile that builds Site.js and serves folder /var/www/html --- Dockerfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e69de29 From d7e539e3c0c72bcc4ca2b3616eb920f5012ecda8 Mon Sep 17 00:00:00 2001 From: alfonsomunozpomer Date: Tue, 29 Dec 2020 02:37:55 +0000 Subject: [PATCH 5/5] Add Dockerfile that builds Site.js and serves folder /var/www/html --- Dockerfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..430df2d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM node:12.16.2-buster-slim + +EXPOSE 80 +EXPOSE 443 + +RUN apt-get update && apt-get -y install git libnss3-tools + +RUN git clone https://github.com/alfonsomunozpomer/site.js.git +WORKDIR /site.js +RUN git checkout docker +RUN npm install && npm install nexe@3.3.7 --save-dev +RUN npm run build && cp dist/release/linux/`ls -1t dist/release/linux | head -1`/site /usr/local/bin + +VOLUME /site.js/dist +VOLUME /var/www/html + +ENTRYPOINT ["site"] +CMD ["serve", "/var/www/html", "--docker"]