Facilitate custom UID/GID at runtime in Docker. (#161)

* Cleanup /scripts dir

* Facilitate custom UID/GID at Docker runtime.

Changes file permissions at runtime depending on UID/GID.

* Disable non-functional frontend tests for now.

---------

Co-authored-by: antanst <>
This commit is contained in:
Antonis Anastasiadis 2025-07-15 21:25:06 +03:00 committed by GitHub
parent ee37441ad0
commit dad0bd45ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 97 additions and 4551 deletions

View file

@ -0,0 +1,56 @@
#!/bin/sh
set -eu
# Runtime UID/GID Configuration
# This script allows setting the user ID and group ID at runtime using PUID and PGID environment variables
# This solves the issue where hardcoded UID/GID (1001:1001) conflicts with host system users
# Get runtime UID/GID from environment variables, fallback to build-time defaults
PUID=${PUID:-${APP_UID:-1001}}
PGID=${PGID:-${APP_GID:-1001}}
# Get current app user/group info
CURRENT_UID=$(id -u app)
CURRENT_GID=$(id -g app)
echo "Runtime UID/GID Configuration"
echo "Current: $CURRENT_UID:$CURRENT_GID"
echo "Target: $PUID:$PGID"
# Only modify user/group if different from current
if [ "$CURRENT_UID" != "$PUID" ] || [ "$CURRENT_GID" != "$PGID" ]; then
echo "Configuring user permissions..."
deluser app 2>/dev/null || true
delgroup app 2>/dev/null || true
if getent group "$PGID" >/dev/null 2>&1; then
TARGET_GROUP=$(getent group "$PGID" | cut -d: -f1)
echo "Using existing group: $TARGET_GROUP ($PGID)"
else
addgroup -g "$PGID" -S app
TARGET_GROUP="app"
echo "Created app group with GID: $PGID"
fi
if getent passwd "$PUID" >/dev/null 2>&1; then
echo "Using existing user with UID $PUID"
else
adduser -S app -u "$PUID" -G "$TARGET_GROUP"
echo "Created user with UID: $PUID, GID: $PGID"
fi
echo "Fixing ownership of application directories..."
chown -R app:$TARGET_GROUP /app
mkdir -p /app/backend/db /app/backend/certs
chown -R app:$TARGET_GROUP /app/backend/db /app/backend/certs
chmod 770 /app/backend/db /app/backend/certs
echo "User configuration completed"
else
echo "No user configuration needed"
fi
# Drop privileges and execute the original start script
echo "🚀 Starting application as user $(id -u app):$(id -g app)"
exec su-exec app dumb-init -- /app/backend/cmd/start.sh

View file

@ -1,55 +0,0 @@
#!/bin/bash
echo "🌍 Translation Sync Script Examples"
echo "=================================="
echo ""
echo "📋 Prerequisites:"
echo "1. Set your OpenAI API key: export OPENAI_API_KEY=\"your-key-here\""
echo "2. Install dependencies: cd scripts && npm install"
echo ""
echo "📖 Basic Usage Examples:"
echo ""
echo "# Check what would be updated (dry run):"
echo "npm run translations:dry-run"
echo ""
echo "# Update all languages:"
echo "npm run translations:sync-all"
echo ""
echo "# Update specific languages:"
echo "npm run translations:sync -- --lang=jp,de"
echo ""
echo "# Check specific language:"
echo "npm run translations:sync -- --lang=es --dry-run"
echo ""
echo "🔧 Direct Script Usage:"
echo ""
echo "# From scripts directory:"
echo "cd scripts"
echo "./sync-translations.js --all"
echo "./sync-translations.js --lang=jp,el,de"
echo "./sync-translations.js --lang=it --dry-run"
echo ""
echo "📊 Current Status:"
if [ -z "$OPENAI_API_KEY" ]; then
echo "❌ OPENAI_API_KEY not set"
else
echo "✅ OPENAI_API_KEY is configured"
fi
echo ""
echo "🗂️ Available Languages:"
echo "- de (German)"
echo "- es (Spanish)"
echo "- el (Greek)"
echo "- it (Italian)"
echo "- jp (Japanese)"
echo "- ua (Ukrainian)"

File diff suppressed because it is too large Load diff

View file

@ -1,28 +0,0 @@
{
"name": "tududi-translation-scripts",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tududi-translation-scripts",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"commander": "^11.0.0"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/commander": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
"license": "MIT",
"engines": {
"node": ">=16"
}
}
}
}

View file

@ -1,17 +0,0 @@
{
"name": "tududi-translation-scripts",
"version": "1.0.0",
"description": "Translation management scripts for tududi",
"main": "sync-translations.js",
"scripts": {
"sync": "node sync-translations.js"
},
"dependencies": {
"commander": "^11.0.0"
},
"engines": {
"node": ">=14.0.0"
},
"author": "tududi team",
"license": "MIT"
}