From 8fa3f93c734ea9305e9bd5b3100816eb373b64a0 Mon Sep 17 00:00:00 2001 From: thursday Date: Mon, 23 Aug 2021 18:09:33 +0000 Subject: Update entrypoint.sh Fixed error causing Ferdi-server's Adonis APP_KEY not to be read from FERDI_APP_KEY.txt on container restart, which was causing the following error: ``` RuntimeException: E_MISSING_APP_KEY: Make sure to define appKey inside config/app.js file before using Encryption provider > More details: https://err.sh/adonisjs/errors/E_MISSING_APP_KEY RuntimeException: E_MISSING_APP_KEY: Make sure to define appKey inside config/app.js file before using Encryption provider > More details: https://err.sh/adonisjs/errors/E_MISSING_APP_KEY at Function.missingAppKey (/app/node_modules/@adonisjs/generic-exceptions/src/RuntimeException.js:54:12) at new Encryption (/app/node_modules/@adonisjs/framework/src/Encryption/index.js:33:33) at Object.closure (/app/node_modules/@adonisjs/framework/providers/AppProvider.js:257:14) at Ioc._resolveBinding (/app/node_modules/@adonisjs/fold/src/Ioc/index.js:231:68) at Ioc.make (/app/node_modules/@adonisjs/fold/src/Ioc/index.js:807:19) at /app/node_modules/@adonisjs/fold/src/Ioc/index.js:318:19 at Array.map () at Ioc._makeInstanceOf (/app/node_modules/@adonisjs/fold/src/Ioc/index.js:317:44) at Ioc.make (/app/node_modules/@adonisjs/fold/src/Ioc/index.js:799:19) at AuthManager.getScheme (/app/node_modules/@adonisjs/auth/src/Auth/Manager.js:86:16) at Auth.authenticator (/app/node_modules/@adonisjs/auth/src/Auth/index.js:118:40) at new Auth (/app/node_modules/@adonisjs/auth/src/Auth/index.js:68:39) at Context. (/app/node_modules/@adonisjs/auth/providers/AuthProvider.js:151:14) at Context.wrappedCallback [as auth] (/app/node_modules/macroable/index.js:132:61) at Server._handleException (/app/node_modules/@adonisjs/framework/src/Server/index.js:253:63) at /app/node_modules/@adonisjs/framework/src/Server/index.js:441:14 ``` --- docker/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 0679530..2d1fd89 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -18,7 +18,7 @@ EOL if [[ -f "${DATA_DIR}/FERDI_APP_KEY.txt" ]]; then echo " " echo "**** App Key found ****" - APP_KEY=$(echo "${APP_KEY}") + APP_KEY=$(cat /data/FERDI_APP_KEY.txt) echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" elif [[ -z "${APP_KEY}" ]]; then echo "**** Generating Ferdi-server app key for first run ****" -- cgit v1.2.3-54-g00ecf From 7884354ef177dac4750e15c448b69fa5b56e5465 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Sep 2021 21:14:04 +0000 Subject: Bump tar from 4.4.15 to 4.4.19 Bumps [tar](https://github.com/npm/node-tar) from 4.4.15 to 4.4.19. - [Release notes](https://github.com/npm/node-tar/releases) - [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/node-tar/compare/v4.4.15...v4.4.19) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 96 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 41 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8994e44..71640e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2740,14 +2740,6 @@ "universalify": "^0.1.0" } }, - "fs-minipass": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz", - "integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==", - "requires": { - "minipass": "^2.2.1" - } - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3989,23 +3981,6 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, - "minipass": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", - "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", - "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" - } - }, - "minizlib": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", - "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", - "requires": { - "minipass": "^2.2.1" - } - }, "mixin-deep": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", @@ -6339,19 +6314,37 @@ } }, "tar": { - "version": "4.4.15", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.15.tgz", - "integrity": "sha512-ItbufpujXkry7bHH9NpQyTXPbJ72iTlXgkBAYsAjDXk3Ds8t/3NfO5P4xZGy7u+sYuQUbimgzswX4uQIEeNVOA==", - "requires": { - "chownr": "^1.1.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.8.6", - "minizlib": "^1.2.1", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.3" + "version": "4.4.19", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.19.tgz", + "integrity": "sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==", + "requires": { + "chownr": "^1.1.4", + "fs-minipass": "^1.2.7", + "minipass": "^2.9.0", + "minizlib": "^1.3.3", + "mkdirp": "^0.5.5", + "safe-buffer": "^5.2.1", + "yallist": "^3.1.1" }, "dependencies": { + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, + "fs-minipass": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", + "requires": { + "minipass": "^2.6.0" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, "minipass": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", @@ -6360,6 +6353,32 @@ "safe-buffer": "^5.1.2", "yallist": "^3.0.0" } + }, + "minizlib": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", + "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", + "requires": { + "minipass": "^2.9.0" + } + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" } } }, @@ -6920,11 +6939,6 @@ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" }, - "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" - }, "youch": { "version": "2.0.10", "resolved": "https://registry.npmjs.org/youch/-/youch-2.0.10.tgz", -- cgit v1.2.3-54-g00ecf From d3ad6f43b9e15df91020576a042621089db2ca2f Mon Sep 17 00:00:00 2001 From: thursday Date: Thu, 16 Sep 2021 17:32:28 -0400 Subject: Update entrypoint.sh --- docker/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 2d1fd89..abd0ed3 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -18,7 +18,7 @@ EOL if [[ -f "${DATA_DIR}/FERDI_APP_KEY.txt" ]]; then echo " " echo "**** App Key found ****" - APP_KEY=$(cat /data/FERDI_APP_KEY.txt) + APP_KEY=$(cat "${DATA_DIR}/FERDI_APP_KEY.txt") echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" elif [[ -z "${APP_KEY}" ]]; then echo "**** Generating Ferdi-server app key for first run ****" -- cgit v1.2.3-54-g00ecf From 1122af152e71d4d353ff8de36807f8f8d1393244 Mon Sep 17 00:00:00 2001 From: thursday Date: Fri, 17 Sep 2021 08:28:46 +0000 Subject: Fixed shebang and simplfied if statement. --- docker/entrypoint.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index abd0ed3..2a91839 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -echo << EOL +cat << EOL ------------------------------------- ____ ___ / __/__ _______/ (_) @@ -15,23 +15,20 @@ https://opencollective.com/getferdi/ EOL # Create APP key if needed -if [[ -f "${DATA_DIR}/FERDI_APP_KEY.txt" ]]; then - echo " " - echo "**** App Key found ****" - APP_KEY=$(cat "${DATA_DIR}/FERDI_APP_KEY.txt") - echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" -elif [[ -z "${APP_KEY}" ]]; then +if [[ -z ${APP_KEY} && ! -f "${DATA_DIR}/FERDI_APP_KEY.txt" ]]; then echo "**** Generating Ferdi-server app key for first run ****" adonis key:generate APP_KEY=$(grep APP_KEY .env | cut -d '=' -f2) echo "${APP_KEY}" > "${DATA_DIR}/FERDI_APP_KEY.txt" echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" +else APP_KEY=$(cat "${DATA_DIR}/FERDI_APP_KEY.txt") + echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" fi export APP_KEY node ace migration:run --force -chown -R ${PUID:-1000}:${PGID:-1000} $DATA_DIR /app +chown -R "${PUID:-1000}":"${PGID:-1000}" "$DATA_DIR" /app -su-exec ${PUID:-1000}:${PGID:-1000} node server.js +su-exec "${PUID:-1000}":"${PGID:-1000}" node server.js#!/bin/bash -- cgit v1.2.3-54-g00ecf From 7a73d967e9c99cd953689869f99c12566d316b57 Mon Sep 17 00:00:00 2001 From: thursday Date: Fri, 17 Sep 2021 08:42:07 +0000 Subject: Fixed NGINX config example indentation. --- docker/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker/README.md b/docker/README.md index 3d8bd5f..33e78c0 100644 --- a/docker/README.md +++ b/docker/README.md @@ -161,15 +161,15 @@ server { listen 443 ssl http2; server_name ferdi.my.website; - # all ssl related config moved to ssl.conf + # all ssl related config moved to ssl.conf include /config/nginx/ssl.conf; location / { - proxy_pass http://:3333; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://:3333; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Proto $scheme; } } ``` -- cgit v1.2.3-54-g00ecf From 085916c33d28408739e0cf886d2ae4316cb92ee4 Mon Sep 17 00:00:00 2001 From: Edgars Date: Wed, 6 Oct 2021 10:52:09 +0300 Subject: Fix `docker/entrypoint.sh` `docker/entrypoint.sh` was updated to fix errors that results in a container that runs on a locally built Ferdi Server image. Fixes that were made: - shebang was changed to `#!/bin/sh` as the Node Alpine image does not have `bash`, therefore the container cannot start because of the error "/usr/local/bin/docker-entrypoint.sh: exec: line 8: /entrypoint.sh: not found"; - `if` condition was updated to make it more portable so it works with non-Bash shells; - `su-exec` command was updated to remove the redundant `#!/bin/bash` from the end of the line as it was causing the error "Error: Cannot find module '/app/server.js#!/bin/bash'". Additional code optimization changes: - tabs were replaced with spaces; - optimizations to avoid code duplication: - new variable `key_file` was added to hold the path to the Ferdi app key file; - the function `print_app_key_message` was added to print the informational message about the app key. --- docker/entrypoint.sh | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 2a91839..2e58abc 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh cat << EOL ------------------------------------- @@ -14,21 +14,31 @@ Support our Open Collective at: https://opencollective.com/getferdi/ EOL +key_file="${DATA_DIR}/FERDI_APP_KEY.txt" + +print_app_key_message() { + app_key=$1 + printf '**** App key is %s. ' ${app_key} + printf 'You can modify `%s` to update the app key ****\n' ${key_file} +} + # Create APP key if needed -if [[ -z ${APP_KEY} && ! -f "${DATA_DIR}/FERDI_APP_KEY.txt" ]]; then - echo "**** Generating Ferdi-server app key for first run ****" - adonis key:generate - APP_KEY=$(grep APP_KEY .env | cut -d '=' -f2) - echo "${APP_KEY}" > "${DATA_DIR}/FERDI_APP_KEY.txt" - echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" -else APP_KEY=$(cat "${DATA_DIR}/FERDI_APP_KEY.txt") - echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" +if [ -z ${APP_KEY} ] && [ ! -f ${key_file} ] +then + echo '**** Generating Ferdi-server app key for first run ****' + adonis key:generate + APP_KEY=$(grep APP_KEY .env | cut -d '=' -f2) + echo ${APP_KEY} > ${key_file} + print_app_key_message ${APP_KEY} +else + APP_KEY=$(cat ${key_file}) + print_app_key_message ${APP_KEY} fi export APP_KEY node ace migration:run --force -chown -R "${PUID:-1000}":"${PGID:-1000}" "$DATA_DIR" /app +chown -R "${PUID:-1000}":"${PGID:-1000}" "${DATA_DIR}" /app -su-exec "${PUID:-1000}":"${PGID:-1000}" node server.js#!/bin/bash +su-exec "${PUID:-1000}":"${PGID:-1000}" node server.js -- cgit v1.2.3-54-g00ecf From f07009cf7633b30057ac6ac5cd16eb583d4117c2 Mon Sep 17 00:00:00 2001 From: Edgars Date: Wed, 6 Oct 2021 10:54:09 +0300 Subject: Exclude `docker-compose.override.yml` from repo `docker/.gitignore` was added to exclude `docker/docker-compose.override.yml` from the repository in case anyone decides to create it to locally override `docker/docker-compose.yml`. --- docker/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 docker/.gitignore diff --git a/docker/.gitignore b/docker/.gitignore new file mode 100644 index 0000000..7376571 --- /dev/null +++ b/docker/.gitignore @@ -0,0 +1 @@ +docker-compose.override.yml -- cgit v1.2.3-54-g00ecf From a4684e1d60ff6932a1bab89ef1a0fbdd10956c3d Mon Sep 17 00:00:00 2001 From: Edgars Date: Fri, 8 Oct 2021 10:51:48 +0300 Subject: Upgrade the Node package `pg` to at least 8.0.3 `package.json` and `package-lock.json` were updated to upgrade the Node package `pg` to at least version 8.0.3 to fix the following error: SubError [TimeoutError]: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call? at /app/node_modules/knex/lib/client.js:339:13 at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23) at /app/node_modules/bluebird/js/release/catch_filter.js:17:41 at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:517:31) at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:574:18) at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:619:10) at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:695:18) at _drainQueueStep (/app/node_modules/bluebird/js/release/async.js:138:12) at _drainQueue (/app/node_modules/bluebird/js/release/async.js:131:9) at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:147:5) at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/release/async.js:17:14) at processImmediate (internal/timers.js:464:21) { sql: undefined, bindings: undefined } --- package-lock.json | 91 +++++++++++++++++++++++++++---------------------------- package.json | 2 +- 2 files changed, 46 insertions(+), 47 deletions(-) diff --git a/package-lock.json b/package-lock.json index 25f4a92..47af2b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4727,46 +4727,38 @@ "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, "pg": { - "version": "7.18.2", - "resolved": "https://registry.npmjs.org/pg/-/pg-7.18.2.tgz", - "integrity": "sha512-Mvt0dGYMwvEADNKy5PMQGlzPudKcKKzJds/VbOeZJpb6f/pI3mmoXX0JksPgI3l3JPP/2Apq7F36O63J7mgveA==", + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.7.1.tgz", + "integrity": "sha512-7bdYcv7V6U3KAtWjpQJJBww0UEsWuh4yQ/EjNf2HeO/NnvKjpvhEIe/A/TleP6wtmSKnUnghs5A9jUoK6iDdkA==", "requires": { "buffer-writer": "2.0.0", "packet-reader": "1.0.0", - "pg-connection-string": "0.1.3", - "pg-packet-stream": "^1.1.0", - "pg-pool": "^2.0.10", + "pg-connection-string": "^2.5.0", + "pg-pool": "^3.4.1", + "pg-protocol": "^1.5.0", "pg-types": "^2.1.0", - "pgpass": "1.x", - "semver": "4.3.2" - }, - "dependencies": { - "semver": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.2.tgz", - "integrity": "sha1-x6BxWKgL7dBSNVt3DYLWZA+AO+c=" - } + "pgpass": "1.x" } }, "pg-connection-string": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-0.1.3.tgz", - "integrity": "sha1-2hhHsglA5C7hSSvq9l1J2RskXfc=" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz", + "integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ==" }, "pg-int8": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==" }, - "pg-packet-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pg-packet-stream/-/pg-packet-stream-1.1.0.tgz", - "integrity": "sha512-kRBH0tDIW/8lfnnOyTwKD23ygJ/kexQVXZs7gEyBljw4FYqimZFxnMMx50ndZ8In77QgfGuItS5LLclC2TtjYg==" - }, "pg-pool": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-2.0.10.tgz", - "integrity": "sha512-qdwzY92bHf3nwzIUcj+zJ0Qo5lpG/YxchahxIN8+ZVmXqkahKXsnl2aiJPHLYN9o5mB/leG+Xh6XKxtP7e0sjg==" + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.4.1.tgz", + "integrity": "sha512-TVHxR/gf3MeJRvchgNHxsYsTCHQ+4wm3VIHSS19z8NC0+gioEhq1okDY1sm/TYbfoP6JLFx01s0ShvZ3puP/iQ==" + }, + "pg-protocol": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.5.0.tgz", + "integrity": "sha512-muRttij7H8TqRNu/DxrAJQITO4Ac7RmX3Klyr/9mJEOBeIpgnF8f9jAfRz5d3XwQZl5qBjF9gLsUtMPJE0vezQ==" }, "pg-types": { "version": "2.2.0", @@ -4781,11 +4773,11 @@ } }, "pgpass": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.2.tgz", - "integrity": "sha1-Knu0G2BltnkH6R2hsHwYR8h3swY=", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.4.tgz", + "integrity": "sha512-YmuA56alyBq7M59vxVBfPJrGSozru8QAdoNlWuW3cz8l+UX3cWge0vTvjKhsSHSJpo3Bom8/Mm6hf0TR5GY0+w==", "requires": { - "split": "^1.0.0" + "split2": "^3.1.1" } }, "pify": { @@ -4842,9 +4834,9 @@ "integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU=" }, "postgres-date": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.4.tgz", - "integrity": "sha512-bESRvKVuTrjoBluEcpv2346+6kgB7UlnqWZsnbnCccTNq/pqfj1j6oBaN5+b/NrDXepYUT/HKadqv3iS9lJuVA==" + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==" }, "postgres-interval": { "version": "1.2.0", @@ -6016,14 +6008,6 @@ "integrity": "sha512-Ki212dKK4ogX+xDo4CtOZBVIwhsKBEfsEEcwmJfLQzirgc2jIWdzg40Unxz/HzEUqM1WFzVlQSMF9kZZ2HboLQ==", "dev": true }, - "split": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", - "requires": { - "through": "2" - } - }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -6051,6 +6035,26 @@ } } }, + "split2": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", + "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", + "requires": { + "readable-stream": "^3.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -6494,11 +6498,6 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" - }, "tildify": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/tildify/-/tildify-1.2.0.tgz", diff --git a/package.json b/package.json index eb5c3a2..cfb563f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "fs-extra": "^8.1.0", "mysql": "2.18.1", "node-fetch": "^2.6.1", - "pg": "^7.18.2", + "pg": "^8.0.3", "sqlite3": "^4.1.0", "targz": "^1.0.1", "uuid": "^8.3.2" -- cgit v1.2.3-54-g00ecf From 05f4ab929ebe4a7db85358e27ba9c9639c1525e4 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sat, 30 Oct 2021 07:43:12 +0530 Subject: Do not error out if husky has not been installed. Ignore .husky folder from Docker context --- .dockerignore | 4 +--- .husky/pre-commit | 9 +++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index 110334e..e97b248 100644 --- a/.dockerignore +++ b/.dockerignore @@ -15,6 +15,4 @@ docker !docker/entrypoint.sh !docker/.env node_modules - - - +.husky diff --git a/.husky/pre-commit b/.husky/pre-commit index 20d0d06..1a92cb3 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,9 @@ #!/bin/sh -. "$(dirname "$0")/_/husky.sh" -npm run lint +FILE_NAME="$(dirname "$0")/_/husky.sh" + +# Conditionally invoke so as to avoid running npm commands if this is a clean checkout (ie before installing npm modules) +if [ -f $FILE_NAME ]; then + . $FILE_NAME + npm run lint +fi -- cgit v1.2.3-54-g00ecf From 6cdbd63621f7ba4062c8e04c763dc91214fdd9e9 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sat, 30 Oct 2021 07:43:41 +0530 Subject: Lock Docker base image to 14.17 as expected by the server code. --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 31dc994..ad057dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:lts-alpine as build +FROM node:14.17-alpine as build WORKDIR /server-build @@ -8,12 +8,12 @@ COPY . /server-build RUN ["npm", "ci", "--production", "--build-from-source", "--sqlite=/usr/local"] -FROM node:lts-alpine +FROM node:14.17-alpine WORKDIR /app LABEL maintainer="xthursdayx" -ENV HOST=0.0.0.0 PORT=3333 DATA_DIR="/data" +ENV HOST=0.0.0.0 PORT=3333 DATA_DIR="/data" RUN ["apk", "add", "--no-cache", "sqlite-libs", "curl", "su-exec"] -- cgit v1.2.3-54-g00ecf From 4fd78e0deddcb51a0b4e07c64d2013fe545179a5 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sat, 30 Oct 2021 10:10:36 +0530 Subject: Fix some more documentation --- CONTRIBUTING.md | 12 ++++++------ README.md | 4 ++-- docker/README.md | 50 ++++++++++++++++++++++++-------------------------- 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 440cc19..1c326b8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -116,9 +116,9 @@ mkdir -p data - Run the database migrations with - ```bash - node ace migration:refresh - ``` +```bash +node ace migration:refresh +``` - To get the full functionality, you will need to have an SMTP server running for local development. @@ -132,9 +132,9 @@ cd recipes && npm i && npm run package ### Start development app - ```bash - npm start --dev - ``` +```bash +npm start --dev +``` ### Styleguide diff --git a/README.md b/README.md index 6a45b08..853d019 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Official Server software for the [Ferdi Messaging Browser](https://getferdi.com) - [Ferdi-server](#ferdi-server) - - [Why use a custom Ferdi server?](#why-use-a-custom-ferdi-server) + - [Why use a custom Ferdi-server?](#why-use-a-custom-ferdi-server) - [Features](#features) - [Setup](#setup) - [with Docker](#with-docker) @@ -89,7 +89,7 @@ For more information on configuring the Docker image, please read [the Ferdi doc ### Manual setup -1. Clone this repository +1. Clone repository with submodule 2. Install the [AdonisJS CLI](https://adonisjs.com/) 3. Copy `.env.example` to `.env` and edit the [configuration](#configuration) to your needs 4. Have env DB_SSL=true only if your database is postgres and it is hosted online on platforms like GCP, AWS, etc diff --git a/docker/README.md b/docker/README.md index 33e78c0..7581bef 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,5 +1,5 @@ # Ferdi-server-docker -[Ferdi](https://github.com/getferdi/ferdi) is a hard-fork of [Franz](https://github.com/meetfranz/franz), adding awesome features and removing unwanted ones. Ferdi-server is an unofficial replacement of the Franz server for use with the Ferdi Client. +[Ferdi](https://github.com/getferdi/ferdi) is a hard-fork of [Franz](https://github.com/meetfranz/franz), adding awesome features and removing unwanted ones. Ferdi-server is an unofficial replacement of the Franz server for use with the Ferdi Client. This is a dockerized version of [Ferdi-server](https://github.com/getferdi/server) running on Alpine Linux and Node.js (v10.16.3). @@ -35,7 +35,7 @@ To create the docker container with the proper parameters: docker create \ --name=ferdi-server \ -e NODE_ENV=development \ - -e EXTERNAL_DOMAIN= \ + -e EXTERNAL_DOMAIN= \ -e DB_CONNECTION= \ -e DB_HOST= \ -e DB_PORT= \ @@ -65,15 +65,15 @@ To create the docker container with the proper parameters: You can use the provided sample [docker-compose.yml](https://github.com/getferdi/server/tree/master/docker/docker-compose.yml) if you are happy with the default environmental variables. This will pull the latest image from Docker Hub or use a local copy of the image which you can build using the instructions provided in the [Building locally section](#building-locally). - To start the application, use `docker-compose up -d`. + To start the application, use `docker-compose -f docker/docker-compose.yml up -d`. The server will be launched at [http://localhost:3333/](http://localhost:3333/) address. ## Configuration Container images are configured using parameters passed at runtime (such as those above). An explanaition of the default parameters is included below, but please see [the Docker documentation](https://docs.docker.com/get-started/overview/) for additional information. -If any environmental parameter is not passed to the container, its value will be taken from the `/config/config.txt` file. -**Warning, the use of `config.txt` is now deprecated. Please make sure to pass the correct environmental variables to your container at runtime. ** +If any environmental parameter is not passed to the container, its value will be taken from the `/config/config.txt` file. +**Warning, the use of `config.txt` is now deprecated. Please make sure to pass the correct environmental variables to your container at runtime. ** | Parameter | Function | | :----: | --- | @@ -108,7 +108,7 @@ By enabling the `CONNECT_WITH_FRANZ` option, Ferdi-server can: ## Supported databases and drivers -To use a different database than the default, SQLite3, enter the driver code below in your ENV configuration. +To use a different database than the default, SQLite3, enter the driver code below in your ENV configuration. | Database | Driver | | :----: | --- | @@ -150,7 +150,7 @@ If you are an existing Ferdi-server user who usees an external database or diffe | `-v :/app/recipes` | this will strore Ferdi-server's recipes on the docker host for persistence | **In eithr case, pleasee be sure to pass the correct variables to the new Ferdi-server container in order maintain access to your existing database.** - + ## NGINX config block To access Ferdi-server from outside of your home network on a subdomain use this server block: @@ -158,19 +158,19 @@ To access Ferdi-server from outside of your home network on a subdomain use this ``` # Ferdi-server server { - listen 443 ssl http2; - server_name ferdi.my.website; - - # all ssl related config moved to ssl.conf - include /config/nginx/ssl.conf; - - location / { - proxy_pass http://:3333; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-Proto $scheme; - } + listen 443 ssl http2; + server_name ferdi.my.website; + + # all ssl related config moved to ssl.conf + include /config/nginx/ssl.conf; + + location / { + proxy_pass http://:3333; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Proto $scheme; + } } ``` @@ -217,15 +217,13 @@ Below are the instructions for updating the container to get the most recent ver * Delete the container: `docker rm ferdi-server` * Recreate a new container with the same docker create parameters as instructed above (if mapped correctly to a host folder, your `/config` folder and ENV settings will be preserved) * Start the new container: `docker start ferdi-server` -* You can also remove the old dangling images: `docker image prune` ### Via Docker Compose -* Update all images: `docker-compose pull` - * or update a single image: `docker-compose pull ferdi-server` -* Let compose update all containers as necessary: `docker-compose up -d` - * or update a single container: `docker-compose up -d ferdi-server` -* You can also remove the old dangling images: `docker image prune` +* Update all images: `docker-compose -f docker/docker-compose.yml pull` + * or update a single image: `docker-compose -f docker/docker-compose.yml pull ferdi-server` +* Let compose update all containers as necessary: `docker-compose -f docker/docker-compose.yml up -d` + * or update a single container: `docker-compose -f docker/docker-compose.yml up -d ferdi-server` ## Building locally -- cgit v1.2.3-54-g00ecf From 24776db01d435ae963d44ece9420d2b2d65a3d39 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sat, 30 Oct 2021 13:18:07 +0530 Subject: Fix some more documentation --- CONTRIBUTING.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c326b8..a0b4c0b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,6 +17,7 @@ - [Git](#git) - [Clone repository with submodule](#clone-repository-with-submodule) - [Install dependencies](#install-dependencies) + - [Start development app](#start-development-app) - [Styleguide](#styleguide) - [Git Commit Messages format](#git-commit-messages-format) - [Javascript Coding style-checker](#javascript-coding-style-checker) @@ -87,7 +88,7 @@ cd server git submodule update --init --recursive ``` -It is important you execute the last command to get the required submodules (recipes, server). +It is important you execute the last command to get the required submodules (recipes). ### Install dependencies @@ -122,14 +123,6 @@ node ace migration:refresh - To get the full functionality, you will need to have an SMTP server running for local development. - - ### Start development app ```bash -- cgit v1.2.3-54-g00ecf