feat(setup/docker): auto-set PUID/PGID from invoking user and chown bind-mount folders; create missing data/events dirs
Mirror to GitHub / mirror (push) Successful in 35s
Test and Lint / backend-test (push) Successful in 1m33s
Test and Lint / frontend-test (push) Successful in 2m12s
Version and Release / version-bump (push) Successful in 1m3s
Version and Release / trigger-drone (push) Successful in 3s
Mirror to GitHub / mirror (push) Successful in 35s
Test and Lint / backend-test (push) Successful in 1m33s
Test and Lint / frontend-test (push) Successful in 2m12s
Version and Release / version-bump (push) Successful in 1m3s
Version and Release / trigger-drone (push) Successful in 3s
This commit is contained in:
+18
-1
@@ -352,7 +352,7 @@ setup_docker_installation() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
log_step "Creating application directory at $app_dir"
|
log_step "Creating application directory at $app_dir"
|
||||||
mkdir -p "$app_dir"/{storage/events/{active,archived},logs,backup,config}
|
mkdir -p "$app_dir"/{storage/events/{active,archived},logs,backup,config,data,events}
|
||||||
|
|
||||||
# Clone repository
|
# Clone repository
|
||||||
log_step "Downloading PicPeak..."
|
log_step "Downloading PicPeak..."
|
||||||
@@ -363,6 +363,16 @@ setup_docker_installation() {
|
|||||||
git clone "$REPO_URL" "$app_dir"
|
git clone "$REPO_URL" "$app_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Determine host user for container mapping (PUID/PGID)
|
||||||
|
local host_uid host_gid
|
||||||
|
if [[ -n "${SUDO_USER:-}" ]]; then
|
||||||
|
host_uid=$(id -u "$SUDO_USER" 2>/dev/null || echo 1000)
|
||||||
|
host_gid=$(id -g "$SUDO_USER" 2>/dev/null || echo 1000)
|
||||||
|
else
|
||||||
|
host_uid=$(id -u 2>/dev/null || echo 1000)
|
||||||
|
host_gid=$(id -g 2>/dev/null || echo 1000)
|
||||||
|
fi
|
||||||
|
|
||||||
# Generate secrets
|
# Generate secrets
|
||||||
local jwt_secret=$(generate_jwt_secret)
|
local jwt_secret=$(generate_jwt_secret)
|
||||||
local db_password=$(generate_password)
|
local db_password=$(generate_password)
|
||||||
@@ -382,6 +392,10 @@ JWT_SECRET=$jwt_secret
|
|||||||
# Admin
|
# Admin
|
||||||
ADMIN_EMAIL=$ADMIN_EMAIL
|
ADMIN_EMAIL=$ADMIN_EMAIL
|
||||||
|
|
||||||
|
# Runtime user mapping for Docker bind mounts
|
||||||
|
PUID=$host_uid
|
||||||
|
PGID=$host_gid
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
DB_HOST=postgres
|
DB_HOST=postgres
|
||||||
DB_PORT=5432
|
DB_PORT=5432
|
||||||
@@ -416,6 +430,9 @@ ENABLE_EMAIL_SERVICE=true
|
|||||||
DEFAULT_EXPIRY_DAYS=30
|
DEFAULT_EXPIRY_DAYS=30
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# Ensure bind mounts are writable by mapped user
|
||||||
|
chown -R "$host_uid":"$host_gid" "$app_dir"/storage "$app_dir"/logs "$app_dir"/backup "$app_dir"/data "$app_dir"/events 2>/dev/null || true
|
||||||
|
|
||||||
# Create docker-compose.yml if it doesn't exist
|
# Create docker-compose.yml if it doesn't exist
|
||||||
if [[ ! -f "$app_dir/docker-compose.yml" ]]; then
|
if [[ ! -f "$app_dir/docker-compose.yml" ]]; then
|
||||||
log_step "Creating Docker Compose configuration..."
|
log_step "Creating Docker Compose configuration..."
|
||||||
|
|||||||
Reference in New Issue
Block a user