From 1043d9902f24c9d626a45b9565e64f2f6caa605b Mon Sep 17 00:00:00 2001 From: "Ehsan.Asadi" Date: Wed, 31 Dec 2025 10:41:49 +0330 Subject: [PATCH] fixe --- docker/Dockerfile | 21 +++++++++++++++++---- docker/entrypoint.sh | 44 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index eabd01a..24fe0ba 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -68,8 +68,14 @@ RUN cd /build/peikarband && \ echo "Frontend export completed" && \ if [ -d .web/node_modules/.bin ]; then \ find .web/node_modules/.bin -type f -exec chmod +x {} \; && \ - find .web/node_modules/.bin -type l -exec chmod +x {} \; && \ - echo "✅ Set executable permissions for all .bin files (files and symlinks)"; \ + find .web/node_modules/.bin -type l | while read symlink; do \ + target=$(readlink -f "$symlink" 2>/dev/null || true); \ + if [ -n "$target" ] && [ -f "$target" ]; then \ + chmod +x "$target" 2>/dev/null || true; \ + fi; \ + chmod +x "$symlink" 2>/dev/null || true; \ + done && \ + echo "✅ Set executable permissions for all .bin files (files and symlinks) and their targets"; \ fi # Note: reflex export already builds and installs everything needed @@ -129,11 +135,18 @@ RUN mkdir -p /app/data /app/logs /app/uploaded_files # Set proper permissions for application files # Explicitly set executable permissions for node_modules/.bin files (both files and symlinks) +# Also fix permissions for symlink targets RUN if [ -d /app/peikarband/.web/node_modules/.bin ]; then \ find /app/peikarband/.web/node_modules/.bin -type f -exec chmod +x {} \; && \ - find /app/peikarband/.web/node_modules/.bin -type l -exec chmod +x {} \; && \ + find /app/peikarband/.web/node_modules/.bin -type l | while read symlink; do \ + target=$(readlink -f "$symlink" 2>/dev/null || true); \ + if [ -n "$target" ] && [ -f "$target" ]; then \ + chmod +x "$target" 2>/dev/null || true; \ + fi; \ + chmod +x "$symlink" 2>/dev/null || true; \ + done && \ ls -la /app/peikarband/.web/node_modules/.bin/ | head -20 && \ - echo "✅ Verified executable permissions for .bin files"; \ + echo "✅ Verified executable permissions for .bin files and symlink targets"; \ fi && \ chmod -R 777 /app/data /app/logs /app/uploaded_files diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index da5da8c..7ab045a 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -4,12 +4,46 @@ set -e # Validate node_modules permissions before starting if [ -d /app/peikarband/.web/node_modules/.bin ]; then echo "Checking node_modules/.bin permissions..." - if [ ! -x /app/peikarband/.web/node_modules/.bin/react-router ]; then - echo "WARNING: react-router is not executable, attempting to fix..." - chmod +x /app/peikarband/.web/node_modules/.bin/* 2>/dev/null || true - echo "Permission fix attempted (may fail if running as non-root)" + + REACT_ROUTER_BIN="/app/peikarband/.web/node_modules/.bin/react-router" + + # Check if react-router exists + if [ -e "$REACT_ROUTER_BIN" ]; then + # If it's a symlink, check and fix the target + if [ -L "$REACT_ROUTER_BIN" ]; then + TARGET=$(readlink -f "$REACT_ROUTER_BIN") + echo "react-router is a symlink pointing to: $TARGET" + if [ -f "$TARGET" ] && [ ! -x "$TARGET" ]; then + echo "WARNING: Target file is not executable, attempting to fix..." + chmod +x "$TARGET" 2>/dev/null || true + fi + fi + + # Fix permissions for react-router itself (file or symlink) + if [ ! -x "$REACT_ROUTER_BIN" ]; then + echo "WARNING: react-router is not executable, attempting to fix..." + chmod +x "$REACT_ROUTER_BIN" 2>/dev/null || true + fi + + # Fix all .bin files and their symlink targets + echo "Fixing permissions for all .bin files and symlink targets..." + find /app/peikarband/.web/node_modules/.bin -type f -exec chmod +x {} \; 2>/dev/null || true + find /app/peikarband/.web/node_modules/.bin -type l | while read symlink; do + target=$(readlink -f "$symlink" 2>/dev/null || true) + if [ -n "$target" ] && [ -f "$target" ]; then + chmod +x "$target" 2>/dev/null || true + fi + chmod +x "$symlink" 2>/dev/null || true + done + + # Verify react-router is executable + if [ -x "$REACT_ROUTER_BIN" ]; then + echo "✅ react-router is executable" + else + echo "⚠️ WARNING: react-router may still not be executable (running as non-root)" + fi else - echo "✅ react-router is executable" + echo "⚠️ WARNING: react-router binary not found" fi fi