Compare commits

...

6 Commits

Author SHA1 Message Date
Gitea Actions Bot f2abb40987 chore: bump version to 1.0.115 (backend + frontend) 2025-09-09 15:32:47 +00:00
paul 3697344cd0 fix(setup/native): handle forced updates safely by fetch+checkout/reset instead of pull; stable on rewritten histories
Mirror to GitHub / mirror (push) Successful in 38s
Test and Lint / backend-test (push) Successful in 1m29s
Test and Lint / frontend-test (push) Successful in 2m5s
Version and Release / version-bump (push) Successful in 1m0s
Version and Release / trigger-drone (push) Successful in 3s
2025-09-09 17:27:27 +02:00
Gitea Actions Bot 4aa0ff705f chore: bump version to 1.0.114 (backend + frontend) 2025-09-09 15:25:05 +00:00
paul dc482e614a fix(setup/native): Debian 12 compatibility (reliable RAM detection, sudo-less run_as_user, git safe.directory); ensure SQLite data dir; use user for migrate
Mirror to GitHub / mirror (push) Successful in 40s
Test and Lint / backend-test (push) Successful in 1m37s
Test and Lint / frontend-test (push) Successful in 2m8s
Version and Release / version-bump (push) Successful in 57s
Version and Release / trigger-drone (push) Successful in 3s
2025-09-09 17:19:03 +02:00
Gitea Actions Bot 448882cfef chore: bump version to 1.0.113 (backend + frontend) 2025-09-09 13:31:10 +00:00
paul 7f9cb33a40 chore(native): ensure SQLite data dir exists in setup and at runtime; keep native paths consistent under /opt/picpeak/app
Mirror to GitHub / mirror (push) Successful in 44s
Test and Lint / backend-test (push) Successful in 1m38s
Test and Lint / frontend-test (push) Successful in 2m3s
Version and Release / version-bump (push) Successful in 59s
Version and Release / trigger-drone (push) Successful in 3s
2025-09-09 15:25:04 +02:00
6 changed files with 81 additions and 17 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "picpeak-backend",
"version": "1.0.112",
"version": "1.0.115",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "picpeak-backend",
"version": "1.0.112",
"version": "1.0.115",
"dependencies": {
"@aws-sdk/client-s3": "^3.850.0",
"@aws-sdk/lib-storage": "^3.850.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "picpeak-backend",
"version": "1.0.112",
"version": "1.0.115",
"description": "Backend for PicPeak event photo sharing platform",
"main": "server.js",
"scripts": {
+22 -1
View File
@@ -1,7 +1,28 @@
const fs = require('fs');
const path = require('path');
const knex = require('knex');
const knexConfig = require('../../knexfile');
const logger = require('../utils/logger');
// Ensure SQLite directory exists when using file-based DB (native installs)
try {
const isPostgres = knexConfig && knexConfig.client === 'pg';
if (!isPostgres && knexConfig && knexConfig.connection) {
const filename = typeof knexConfig.connection === 'object'
? knexConfig.connection.filename
: (typeof knexConfig.connection === 'string' ? knexConfig.connection : null);
if (filename && typeof filename === 'string') {
const dir = path.dirname(filename);
if (dir && dir !== '.') {
fs.mkdirSync(dir, { recursive: true });
}
}
}
} catch (e) {
// Non-fatal: log and continue; SQLite will fail later if still missing
try { logger.warn('SQLite directory ensure failed', { error: e.message }); } catch (_) {}
}
// Create database connection with built-in retry logic
const db = knex(knexConfig);
@@ -312,4 +333,4 @@ async function logActivity(activityType, metadata = {}, eventId = null, actor =
}
}
module.exports = { db, initializeDatabase, logActivity, withRetry };
module.exports = { db, initializeDatabase, logActivity, withRetry };
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "picpeak-frontend",
"version": "1.0.112",
"version": "1.0.115",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "picpeak-frontend",
"version": "1.0.112",
"version": "1.0.115",
"dependencies": {
"@tanstack/react-query": "^5.0.0",
"@tiptap/extension-character-count": "^2.26.1",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "picpeak-frontend",
"private": true,
"version": "1.0.112",
"version": "1.0.115",
"type": "module",
"scripts": {
"dev": "vite",
+53 -10
View File
@@ -61,6 +61,23 @@ UNINSTALL_MODE=false
# Helper Functions
################################################################################
# Run a command as the application user, even if sudo is not available
run_as_user() {
local cmd="$*"
if [[ "$(id -u)" -ne 0 ]]; then
# Already non-root; just run
bash -lc "$cmd"
return $?
fi
if command_exists sudo; then
sudo -H -u "$NATIVE_APP_USER" bash -lc "$cmd"
elif command_exists runuser; then
runuser -u "$NATIVE_APP_USER" -- bash -lc "$cmd"
else
su -s /bin/bash - "$NATIVE_APP_USER" -c "$cmd"
fi
}
print_banner() {
echo -e "${PURPLE}"
echo "╔════════════════════════════════════════════════════════════════════════╗"
@@ -110,11 +127,16 @@ generate_jwt_secret() {
}
get_available_ram_mb() {
if command_exists free; then
free -m | awk '/^Mem:/{print $2}'
else
echo "0"
# Prefer /proc/meminfo (always available on Linux), fallback to free(1)
if [[ -r /proc/meminfo ]]; then
awk '/^MemTotal:/ { printf "%d\n", $2/1024 }' /proc/meminfo
return
fi
if command_exists free; then
free -m | awk '/^Mem:/ {print $2}'
return
fi
echo "0"
}
get_available_disk_gb() {
@@ -552,14 +574,26 @@ setup_native_installation() {
# Create application directory
log_step "Creating application directory..."
mkdir -p "$NATIVE_APP_DIR"/{app,events/{active,archived},logs,config}
chown -R $NATIVE_APP_USER:$NATIVE_APP_USER "$NATIVE_APP_DIR"
# Clone repository
log_step "Downloading PicPeak..."
if [[ -d "$NATIVE_APP_DIR/app/.git" ]]; then
cd "$NATIVE_APP_DIR/app"
git pull
# Ensure correct remote and update even if history was rewritten
run_as_user "git config --global --add safe.directory $NATIVE_APP_DIR/app" || true
run_as_user "git remote set-url origin $REPO_URL" || true
run_as_user "git fetch --all --prune" || true
# Prefer checking out remote main and hard resetting to avoid merge prompts
if ! run_as_user "git checkout -B main origin/main"; then
run_as_user "git checkout main" || true
run_as_user "git reset --hard origin/main"
fi
else
git clone "$REPO_URL" "$NATIVE_APP_DIR/app"
run_as_user "git clone $REPO_URL $NATIVE_APP_DIR/app" || {
run_as_user "git config --global --add safe.directory $NATIVE_APP_DIR/app"
run_as_user "git clone $REPO_URL $NATIVE_APP_DIR/app"
}
fi
# Install dependencies
@@ -569,6 +603,9 @@ setup_native_installation() {
cd "$NATIVE_APP_DIR/app/backend"
npm install --production
# Ensure SQLite data directory exists for native installs
mkdir -p "$NATIVE_APP_DIR/app/backend/data"
# Generate secrets
local jwt_secret=$(generate_jwt_secret)
[[ -z "$ADMIN_PASSWORD" ]] && ADMIN_PASSWORD=$(generate_password)
@@ -626,7 +663,7 @@ EOF
# Run database migrations
log_step "Initializing database..."
cd "$NATIVE_APP_DIR/app/backend"
sudo -u $NATIVE_APP_USER npm run migrate
run_as_user "npm run migrate"
# Create systemd services
create_systemd_services
@@ -944,14 +981,20 @@ update_native_installation() {
# Pull latest code
cd "$NATIVE_APP_DIR/app"
sudo -u $NATIVE_APP_USER git pull
run_as_user "git config --global --add safe.directory $NATIVE_APP_DIR/app" || true
run_as_user "git remote set-url origin $REPO_URL" || true
run_as_user "git fetch --all --prune"
if ! run_as_user "git checkout -B main origin/main"; then
run_as_user "git checkout main" || true
run_as_user "git reset --hard origin/main"
fi
# Update backend dependencies
cd "$NATIVE_APP_DIR/app/backend"
sudo -u $NATIVE_APP_USER npm install --production
run_as_user "npm install --production"
# Run migrations
sudo -u $NATIVE_APP_USER npm run migrate
run_as_user "npm run migrate"
# Restart services
systemctl start picpeak-backend picpeak-workers