From 87b8414e449802db6dc9f762453f7672616b83c9 Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 9 Sep 2025 11:13:01 +0200 Subject: [PATCH] fix(setup/native): correct repo URL, paths, and systemd for native install; support sqlite in production knex config --- backend/knexfile.js | 56 ++++++++++++++++++++++++++------------------- scripts/setup.sh | 27 ++++++++++++---------- 2 files changed, 47 insertions(+), 36 deletions(-) diff --git a/backend/knexfile.js b/backend/knexfile.js index 7264510..9704349 100644 --- a/backend/knexfile.js +++ b/backend/knexfile.js @@ -26,29 +26,37 @@ const config = { production: { client: process.env.DATABASE_CLIENT || 'pg', - connection: { - host: process.env.DB_HOST || 'db', - port: process.env.DB_PORT || 5432, - user: process.env.DB_USER || 'picpeak', - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME || 'picpeak', - ssl: process.env.DB_SSL === 'true' ? { rejectUnauthorized: false } : false, - // Connection stability settings - connectionTimeoutMillis: 30000, - idleTimeoutMillis: 30000, - keepAlive: true, - keepAliveInitialDelayMillis: 0 - }, - pool: { - min: 5, - max: 25, - acquireTimeoutMillis: 60000, - createTimeoutMillis: 60000, - idleTimeoutMillis: 30000, - reapIntervalMillis: 1000, - createRetryIntervalMillis: 200, - propagateCreateError: false - }, + // Support both Postgres and SQLite in production based on DATABASE_CLIENT + connection: (process.env.DATABASE_CLIENT || 'pg') === 'pg' + ? { + host: process.env.DB_HOST || 'db', + port: process.env.DB_PORT || 5432, + user: process.env.DB_USER || 'picpeak', + password: process.env.DB_PASSWORD, + database: process.env.DB_NAME || 'picpeak', + ssl: process.env.DB_SSL === 'true' ? { rejectUnauthorized: false } : false, + // Connection stability settings + connectionTimeoutMillis: 30000, + idleTimeoutMillis: 30000, + keepAlive: true, + keepAliveInitialDelayMillis: 0 + } + : { + filename: path.join(__dirname, process.env.DATABASE_PATH || './data/photo_sharing.db') + }, + useNullAsDefault: (process.env.DATABASE_CLIENT || 'pg') !== 'pg', + pool: (process.env.DATABASE_CLIENT || 'pg') === 'pg' + ? { + min: 5, + max: 25, + acquireTimeoutMillis: 60000, + createTimeoutMillis: 60000, + idleTimeoutMillis: 30000, + reapIntervalMillis: 1000, + createRetryIntervalMillis: 200, + propagateCreateError: false + } + : undefined, migrations: { directory: './migrations' }, @@ -56,4 +64,4 @@ const config = { } }; -module.exports = config[process.env.NODE_ENV || 'development']; \ No newline at end of file +module.exports = config[process.env.NODE_ENV || 'development']; diff --git a/scripts/setup.sh b/scripts/setup.sh index dc50d7e..96b8602 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -13,7 +13,7 @@ IFS=$'\n\t' # Script configuration readonly SCRIPT_VERSION="2.0.0" readonly APP_NAME="PicPeak" -readonly REPO_URL="https://github.com/yourusername/wedding-photo-sharing" +readonly REPO_URL="https://github.com/the-luap/picpeak.git" readonly NODE_VERSION="20" readonly MIN_RAM_DOCKER=2048 readonly MIN_RAM_NATIVE=1024 @@ -564,7 +564,9 @@ setup_native_installation() { # Install dependencies log_step "Installing dependencies..." - cd "$NATIVE_APP_DIR/backend" + # The repository root contains both backend/ and frontend/ + # Install backend production dependencies + cd "$NATIVE_APP_DIR/backend/backend" npm install --production # Generate secrets @@ -573,7 +575,7 @@ setup_native_installation() { # Create .env file log_step "Creating configuration..." - cat > "$NATIVE_APP_DIR/backend/.env" < "$NATIVE_APP_DIR/backend/backend/.env" <