From 794108b4d555d82e59d476d823d5cb87791a67fc Mon Sep 17 00:00:00 2001 From: Michal Kostewicz Date: Sun, 7 Feb 2021 12:44:46 +0100 Subject: Change database.js so any system folder can be used to keep database files --- config/database.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/database.js') diff --git a/config/database.js b/config/database.js index b7f57ad..6e08035 100644 --- a/config/database.js +++ b/config/database.js @@ -31,7 +31,7 @@ module.exports = { sqlite: { client: 'sqlite3', connection: { - filename: Helpers.appRoot(`${Env.get('DATA_DIR', 'database')}/${Env.get('DB_DATABASE', 'development')}.sqlite`), + filename: `${Env.get('DATA_DIR', 'database')}/${Env.get('DB_DATABASE', 'development')}.sqlite`, }, useNullAsDefault: true, debug: Env.get('DB_DEBUG', false), -- cgit v1.2.3-54-g00ecf From 02000d89159ba171cabbd341139871236f3df386 Mon Sep 17 00:00:00 2001 From: Michal Kostewicz Date: Sun, 7 Feb 2021 14:23:57 +0100 Subject: Revert line which choose DB folder using env. Move Dockerfile to root. Simplify export in entrypoint. Update README --- Dockerfile | 26 ++++++++++++++++++++++++++ README.md | 40 +--------------------------------------- config/database.js | 2 +- docker/Dockerfile | 27 --------------------------- docker/README.md | 1 + docker/docker-compose.yml | 6 +++--- docker/entrypoint.sh | 2 +- 7 files changed, 33 insertions(+), 71 deletions(-) create mode 100644 Dockerfile delete mode 100644 docker/Dockerfile (limited to 'config/database.js') diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..416c503 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM node:lts-alpine as build + +WORKDIR /server-build + +RUN ["apk", "add", "--no-cache", "python", "make", "gcc", "g++", "libc-dev", "sqlite-dev"] + +COPY . /server-build + +RUN ["npm", "ci", "--production", "--build-from-source", "--sqlite=/usr/local"] + +FROM node:lts-alpine + +WORKDIR /app +LABEL maintainer="xthursdayx" + +ENV HOST=0.0.0.0 PORT=3333 + +RUN ["apk", "add", "--no-cache", "sqlite-libs", "curl"] + +COPY --from=build /server-build /app +RUN ["npm", "i", "-g", "@adonisjs/cli"] + +HEALTHCHECK --interval=5m --timeout=3s CMD curl -sSf http://localhost:${PORT}/health + +COPY docker/entrypoint.sh /entrypoint.sh +CMD ["/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 9d1b02d..60de4fc 100644 --- a/README.md +++ b/README.md @@ -78,45 +78,7 @@ After setting up the docker container we recommend you to set up an NGINX revers getferdi/ferdi-server ``` - Alternatively, you can also use docker-compose v2 schemas - - ```sh - --- - version: "2" - services: - ferdi-server: - image: getferdi/ferdi-server - container_name: ferdi-server - environment: - - NODE_ENV=development - - EXTERNAL_DOMAIN= - - DB_CONNECTION= - - DB_HOST= - - DB_PORT= - - DB_USER= - - DB_PASSWORD= - - DB_DATABASE= - - DB_SSL=true/false - - MAIL_CONNECTION= - - SMPT_HOST= - - SMTP_PORT= - - MAIL_SSL=true/false - - MAIL_USERNAME= - - MAIL_PASSWORD= - - MAIL_SENDER= - - IS_CREATION_ENABLED=true/false - - IS_DASHBOARD_ENABLED=true/false - - IS_REGISTRATION_ENABLED=true/false - - CONNECT_WITH_FRANZ=true/false - volumes: - - :/config - - :/app/database - - :/app/recipes - ports: - - :80 - restart: unless-stopped - ``` - You can also use sample [./docker/docker-compose.yml](https://github.com/getferdi/server/tree/master/docker/docker-compose.yml) file. + Alternatively, you can also use docker-compose v2 schemas. An example can be found in [./docker/docker-compose.yml](https://github.com/getferdi/server/tree/master/docker/docker-compose.yml) file. 3. Optionally, you can now [set up Nginx as a reverse proxy](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04#set-up-nginx-as-a-reverse-proxy-server). diff --git a/config/database.js b/config/database.js index 6e08035..b7f57ad 100644 --- a/config/database.js +++ b/config/database.js @@ -31,7 +31,7 @@ module.exports = { sqlite: { client: 'sqlite3', connection: { - filename: `${Env.get('DATA_DIR', 'database')}/${Env.get('DB_DATABASE', 'development')}.sqlite`, + filename: Helpers.appRoot(`${Env.get('DATA_DIR', 'database')}/${Env.get('DB_DATABASE', 'development')}.sqlite`), }, useNullAsDefault: true, debug: Env.get('DB_DEBUG', false), diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 799bb0b..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM node:lts-alpine as build - -WORKDIR /server-build - -RUN ["apk", "add", "--no-cache", "python", "make", "gcc", "g++", "libc-dev", "sqlite-dev"] - -COPY . /server-build - -RUN ["npm", "ci", "--production", "--build-from-source", "--sqlite=/usr/local"] - -FROM node:lts-alpine - -WORKDIR /app -LABEL maintainer="xthursdayx" - -ENV HOST=0.0.0.0 PORT=3333 - -RUN ["apk", "add", "--no-cache", "sqlite-libs", "curl"] - -COPY --from=build /server-build /app -RUN ["touch", ".env"] -RUN ["npm", "i", "-g", "@adonisjs/cli"] - -HEALTHCHECK --interval=5m --timeout=3s CMD curl -sSf http://localhost:${PORT}/health - -COPY docker/entrypoint.sh /entrypoint.sh -CMD ["/entrypoint.sh"] \ No newline at end of file diff --git a/docker/README.md b/docker/README.md index 5daa9fc..995ca8a 100644 --- a/docker/README.md +++ b/docker/README.md @@ -101,6 +101,7 @@ After the first run, Ferdi-server's configuration is saved inside the `config.tx | `-e IS_DASHBOARD_ENABLED=true` | for specifying whether to enable the Ferdi-server dashboard, default is true | | `-e IS_REGISTRATION_ENABLED=true` | for specifying whether to allow user registration, default is true | | `-e CONNECT_WITH_FRANZ=true` | for specifying whether to enable connections to the Franz server, default is true | +| `-e DATA_DIR=database` | for specifying sql-lite database folder, default is database | | `-v :/config` | this will store persistent ENV data on the docker host | | `-v :/app/database` | this will strore Ferdi-server's database on the docker host for persistence | | `-v :/app/recipes` | this will strore Ferdi-server's recipes on the docker host for persistence | diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 364f9c3..8a8c795 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -24,10 +24,10 @@ services: - IS_DASHBOARD_ENABLED=true - IS_REGISTRATION_ENABLED=true - CONNECT_WITH_FRANZ=false - - DATA_DIR=/database + - DATA_DIR=my-database volumes: - ferdi-config-vol:/config - - ferdi-database-vol:/database + - ferdi-database-vol:/app/my-database - ferdi-recipes-vol:/app/recipes ports: - 3333:3333 @@ -35,4 +35,4 @@ services: volumes: ferdi-config-vol: ferdi-database-vol: - ferdi-recipes-vol: \ No newline at end of file + ferdi-recipes-vol: diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index cb0dd0f..667196e 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -33,7 +33,7 @@ elif [ -f "/config/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=$APP_KEY +export APP_KEY node ace migration:run --force -- cgit v1.2.3-54-g00ecf From c6483e8effb6e10e889c775b7f647d64e990e86b Mon Sep 17 00:00:00 2001 From: thursday Date: Fri, 9 Jul 2021 17:02:36 -0400 Subject: Update database.js Update default sqlite data directory and database as per: https://github.com/getferdi/server/pull/48#discussion_r667150127 --- config/database.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/database.js') diff --git a/config/database.js b/config/database.js index b7f57ad..f6ede13 100644 --- a/config/database.js +++ b/config/database.js @@ -31,7 +31,7 @@ module.exports = { sqlite: { client: 'sqlite3', connection: { - filename: Helpers.appRoot(`${Env.get('DATA_DIR', 'database')}/${Env.get('DB_DATABASE', 'development')}.sqlite`), + filename: `${Env.get('DATA_DIR', 'data')}/${Env.get('DB_DATABASE', 'database')}.sqlite`, }, useNullAsDefault: true, debug: Env.get('DB_DEBUG', false), -- cgit v1.2.3-54-g00ecf From 68b5c7a287afde31880436b8ea496fa70202fa6d Mon Sep 17 00:00:00 2001 From: thursday Date: Mon, 12 Jul 2021 19:00:00 -0400 Subject: Update database.js Updated the path.join function for the default sqlite database and updated all default database names to `ferdi` rather than `adonis` --- config/database.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'config/database.js') diff --git a/config/database.js b/config/database.js index f6ede13..e5e3ec8 100644 --- a/config/database.js +++ b/config/database.js @@ -31,7 +31,7 @@ module.exports = { sqlite: { client: 'sqlite3', connection: { - filename: `${Env.get('DATA_DIR', 'data')}/${Env.get('DB_DATABASE', 'database')}.sqlite`, + filename: path.join(Env.get('DATA_DIR', 'data'), `${Env.get('DB_DATABASE', 'ferdi')}.sqlite`), }, useNullAsDefault: true, debug: Env.get('DB_DEBUG', false), @@ -54,7 +54,7 @@ module.exports = { port: Env.get('DB_PORT', ''), user: Env.get('DB_USER', 'root'), password: Env.get('DB_PASSWORD', ''), - database: Env.get('DB_DATABASE', 'adonis'), + database: Env.get('DB_DATABASE', 'ferdi'), }, debug: Env.get('DB_DEBUG', false), }, @@ -76,7 +76,7 @@ module.exports = { port: Env.get('DB_PORT', ''), user: Env.get('DB_USER', 'root'), password: Env.get('DB_PASSWORD', ''), - database: Env.get('DB_DATABASE', 'adonis'), + database: Env.get('DB_DATABASE', 'ferdi'), ssl: JSON.parse(Env.get('DB_SSL', 'true')), }, debug: Env.get('DB_DEBUG', false), -- cgit v1.2.3-54-g00ecf From e64389b43067b079382020429961cbd12fc77678 Mon Sep 17 00:00:00 2001 From: thursday Date: Tue, 13 Jul 2021 07:19:58 -0400 Subject: Update database.js Add path for path.join variables. --- config/database.js | 1 + 1 file changed, 1 insertion(+) (limited to 'config/database.js') diff --git a/config/database.js b/config/database.js index e5e3ec8..9372eda 100644 --- a/config/database.js +++ b/config/database.js @@ -1,3 +1,4 @@ +const path = require("path"); /** @type {import('@adonisjs/framework/src/Env')} */ const Env = use('Env'); -- cgit v1.2.3-54-g00ecf From d06b8b5fa0a7e1f9bd89273919db16a6af9e7c11 Mon Sep 17 00:00:00 2001 From: thursday Date: Tue, 13 Jul 2021 07:20:54 -0400 Subject: Update database.js changing docker data_dir to /data --- config/database.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/database.js') diff --git a/config/database.js b/config/database.js index 9372eda..1812295 100644 --- a/config/database.js +++ b/config/database.js @@ -32,7 +32,7 @@ module.exports = { sqlite: { client: 'sqlite3', connection: { - filename: path.join(Env.get('DATA_DIR', 'data'), `${Env.get('DB_DATABASE', 'ferdi')}.sqlite`), + filename: path.join(Env.get('DATA_DIR', '/data'), `${Env.get('DB_DATABASE', 'ferdi')}.sqlite`), }, useNullAsDefault: true, debug: Env.get('DB_DEBUG', false), -- cgit v1.2.3-54-g00ecf From 1b90c82cff122210f8441fe9eef72bce4b3bc3e8 Mon Sep 17 00:00:00 2001 From: thursday Date: Tue, 13 Jul 2021 08:06:21 -0400 Subject: Update database.js reverting DATA_DIR default to data --- config/database.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/database.js') diff --git a/config/database.js b/config/database.js index 1812295..9372eda 100644 --- a/config/database.js +++ b/config/database.js @@ -32,7 +32,7 @@ module.exports = { sqlite: { client: 'sqlite3', connection: { - filename: path.join(Env.get('DATA_DIR', '/data'), `${Env.get('DB_DATABASE', 'ferdi')}.sqlite`), + filename: path.join(Env.get('DATA_DIR', 'data'), `${Env.get('DB_DATABASE', 'ferdi')}.sqlite`), }, useNullAsDefault: true, debug: Env.get('DB_DEBUG', false), -- cgit v1.2.3-54-g00ecf