From c9d1a1229927929b3b998e048c80fb8062e76538 Mon Sep 17 00:00:00 2001 From: Thomas Camlong Date: Tue, 14 Nov 2023 20:31:39 +0100 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=90=9B=20Copy=20`default.json`=20if?= =?UTF-8?q?=20it=20doesn't=20exist=20(#1636)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/run.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/run.sh b/scripts/run.sh index 67c5cb508..ba017d05e 100644 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -8,6 +8,9 @@ cd ./migrate; yarn db:migrate & PID=$! # Wait for migration to finish wait $PID +## If 'default.json' does not exist in '/app/data/configs', we copy it from '/app/data/default.json' +cp -n /app/data/default.json /app/data/configs/default.json + echo "Starting production server..." node /app/server.js & PID=$! From a0efd01d433590be0018f941407fb58193ef0deb Mon Sep 17 00:00:00 2001 From: Meier Lukas Date: Tue, 14 Nov 2023 20:42:17 +0100 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=90=9B=20Error=20object=20not=20compa?= =?UTF-8?q?tible=20with=20json=20parsing=20of=20gssp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Onboarding/database-not-writeable.tsx | 14 +++++++---- src/pages/onboard.tsx | 24 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/components/Onboarding/database-not-writeable.tsx b/src/components/Onboarding/database-not-writeable.tsx index ac1e92527..b2d313a9d 100644 --- a/src/components/Onboarding/database-not-writeable.tsx +++ b/src/components/Onboarding/database-not-writeable.tsx @@ -1,7 +1,13 @@ import { Center, Code, List, Stack, Text, Title } from '@mantine/core'; import Head from 'next/head'; -export const DatabaseNotWriteable = ({ error, errorMessage }: { error: any | unknown, errorMessage: string | undefined }) => { +export const DatabaseNotWriteable = ({ + stringifiedError, + errorMessage, +}: { + stringifiedError: string | undefined; + errorMessage: string | undefined; +}) => { return ( <> @@ -30,11 +36,9 @@ export const DatabaseNotWriteable = ({ error, errorMessage }: { error: any | unk - {error && JSON.stringify(error)} + {stringifiedError} - {errorMessage && ( - {errorMessage} - )} + {errorMessage && {errorMessage}} diff --git a/src/pages/onboard.tsx b/src/pages/onboard.tsx index ab7b4b55d..bad0f1f23 100644 --- a/src/pages/onboard.tsx +++ b/src/pages/onboard.tsx @@ -21,8 +21,8 @@ const exec = util.promisify(require('child_process').exec); export default function OnboardPage({ configSchemaVersions, databaseNotWriteable, - error, - errorMessage + stringifiedError, + errorMessage, }: InferGetServerSidePropsType) { const { fn, colors, colorScheme } = useMantineTheme(); const background = colorScheme === 'dark' ? 'dark.6' : 'gray.1'; @@ -49,7 +49,7 @@ export default function OnboardPage({ {databaseNotWriteable == true ? ( - + ) : ( <> {onboardingSteps ? ( @@ -117,7 +117,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { ...translations, configSchemaVersions: configSchemaVersions, databaseNotWriteable: true, - error: error, + errorMessage: 'Database is not writeable', + stringifiedError: JSON.stringify(error), }, }; } @@ -128,13 +129,18 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { const { stdout, stderr } = await exec("mount | grep '/data'"); if (stderr.split('\n').length > 1 || stdout.split('\n').length <= 1) { - Consola.error(`Database at '${rawDatabaseUrl}' has not been mounted: ${stdout.replace('\n', '\\n')} ${stderr.replace('\n', '\\n')}`); + Consola.error( + `Database at '${rawDatabaseUrl}' has not been mounted: ${stdout.replace( + '\n', + '\\n' + )} ${stderr.replace('\n', '\\n')}` + ); return { props: { ...translations, configSchemaVersions: configSchemaVersions, databaseNotWriteable: true, - error: `Database at '${rawDatabaseUrl}' is not mounted:\n${stdout}`, + errorMessage: `Database at '${rawDatabaseUrl}' is not mounted:\n${stdout}`, }, }; } @@ -146,8 +152,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { ...translations, configSchemaVersions: configSchemaVersions, databaseNotWriteable: true, - error: error, - errorMessage: errorMessage + stringifiedError: JSON.stringify(error), + errorMessage: errorMessage, }, }; } @@ -160,7 +166,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { props: { ...translations, configSchemaVersions: configSchemaVersions, - databaseNotWriteable: false + databaseNotWriteable: false, }, }; }; From f06dff7bb7d3c6f7c602d5f4feed096730b07fc4 Mon Sep 17 00:00:00 2001 From: Meier Lukas Date: Tue, 14 Nov 2023 20:52:05 +0100 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=90=9B=20Add=20production=20environme?= =?UTF-8?q?nt=20check=20before=20checking=20mountpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/onboard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/onboard.tsx b/src/pages/onboard.tsx index bad0f1f23..43331fb63 100644 --- a/src/pages/onboard.tsx +++ b/src/pages/onboard.tsx @@ -124,7 +124,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { } Consola.info('Database is writeable'); - if (process.platform !== 'win32') { + if (process.platform !== 'win32' || env.NEXT_PUBLIC_NODE_ENV === 'development') { try { const { stdout, stderr } = await exec("mount | grep '/data'"); From de2a632a4e8157db0902e618deac017043afc72f Mon Sep 17 00:00:00 2001 From: Meier Lukas Date: Tue, 14 Nov 2023 20:52:22 +0100 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=90=9B=20Failed=20to=20stage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/onboard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/onboard.tsx b/src/pages/onboard.tsx index 43331fb63..c18d7ad9a 100644 --- a/src/pages/onboard.tsx +++ b/src/pages/onboard.tsx @@ -124,7 +124,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { } Consola.info('Database is writeable'); - if (process.platform !== 'win32' || env.NEXT_PUBLIC_NODE_ENV === 'development') { + if (process.platform !== 'win32' && env.NEXT_PUBLIC_NODE_ENV === 'production') { try { const { stdout, stderr } = await exec("mount | grep '/data'"); From a2cfe8391e19bb417ea3622a26e1223587894cb9 Mon Sep 17 00:00:00 2001 From: Meier Lukas Date: Tue, 14 Nov 2023 20:58:08 +0100 Subject: [PATCH 5/6] Remove mount check do to automatic mounting with Volume in Dockerfile --- src/pages/onboard.tsx | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/src/pages/onboard.tsx b/src/pages/onboard.tsx index c18d7ad9a..238d4ef82 100644 --- a/src/pages/onboard.tsx +++ b/src/pages/onboard.tsx @@ -122,42 +122,6 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { }, }; } - Consola.info('Database is writeable'); - - if (process.platform !== 'win32' && env.NEXT_PUBLIC_NODE_ENV === 'production') { - try { - const { stdout, stderr } = await exec("mount | grep '/data'"); - - if (stderr.split('\n').length > 1 || stdout.split('\n').length <= 1) { - Consola.error( - `Database at '${rawDatabaseUrl}' has not been mounted: ${stdout.replace( - '\n', - '\\n' - )} ${stderr.replace('\n', '\\n')}` - ); - return { - props: { - ...translations, - configSchemaVersions: configSchemaVersions, - databaseNotWriteable: true, - errorMessage: `Database at '${rawDatabaseUrl}' is not mounted:\n${stdout}`, - }, - }; - } - } catch (error) { - const errorMessage = `Database at '${rawDatabaseUrl}' has not been mounted: ${error}`; - Consola.error(errorMessage); - return { - props: { - ...translations, - configSchemaVersions: configSchemaVersions, - databaseNotWriteable: true, - stringifiedError: JSON.stringify(error), - errorMessage: errorMessage, - }, - }; - } - } Consola.info(`Database at '${rawDatabaseUrl}' is writeable and mounted`); } From 8ee28767fc03d1de4d43a97ff992eb1858827628 Mon Sep 17 00:00:00 2001 From: Meier Lukas Date: Tue, 14 Nov 2023 21:06:07 +0100 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=90=9B=20Fix=20build=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/onboard.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pages/onboard.tsx b/src/pages/onboard.tsx index 238d4ef82..fef7b63ad 100644 --- a/src/pages/onboard.tsx +++ b/src/pages/onboard.tsx @@ -15,9 +15,6 @@ import { getTotalUserCountAsync } from '~/server/db/queries/user'; import { getConfig } from '~/tools/config/getConfig'; import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations'; -const util = require('util'); -const exec = util.promisify(require('child_process').exec); - export default function OnboardPage({ configSchemaVersions, databaseNotWriteable,