diff --git a/scripts/fix-git-integration-deployment.sh b/scripts/fix-git-integration-deployment.sh new file mode 100755 index 0000000..cdaad5e --- /dev/null +++ b/scripts/fix-git-integration-deployment.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Comprehensive fix for git-integration service deployment failure +# Addresses permission issues and directory setup + +set -e + +echo "🚀 Fixing git-integration service deployment issues..." +echo "==================================================" + +# Define paths +BASE_DIR="/home/ubuntu/codenuk-backend-live" +GIT_REPOS_DIR="$BASE_DIR/git-repos" +DIFFS_DIR="$GIT_REPOS_DIR/diffs" + +# Step 1: Stop the failing service +echo "🛑 Stopping git-integration service..." +cd "$BASE_DIR" +docker compose stop git-integration 2>/dev/null || true +docker compose rm -f git-integration 2>/dev/null || true + +# Step 2: Create and setup directories +echo "📁 Setting up git-repos directories..." +mkdir -p "$GIT_REPOS_DIR" +mkdir -p "$DIFFS_DIR" + +# Step 3: Fix ownership and permissions +echo "👤 Fixing ownership and permissions..." +# UID 1001 matches the git-integration user in the container +sudo chown -R 1001:1001 "$GIT_REPOS_DIR" +chmod -R 755 "$GIT_REPOS_DIR" + +# Step 4: Verify directory setup +echo "✅ Verifying directory setup..." +echo "Directory structure:" +ls -la "$GIT_REPOS_DIR" + +# Step 5: Rebuild and restart the service +echo "🔨 Rebuilding git-integration service..." +docker compose build git-integration + +echo "🚀 Starting git-integration service..." +docker compose up -d git-integration + +# Step 6: Wait for service to start and check health +echo "⏳ Waiting for service to start..." +sleep 10 + +echo "🏥 Checking service health..." +docker compose ps git-integration + +# Step 7: Check logs for any remaining issues +echo "📋 Recent service logs:" +docker compose logs --tail=20 git-integration + +echo "" +echo "🎉 Git-integration service fix completed!" +echo "==================================================" +echo "✅ Directories created with proper permissions" +echo "✅ Service rebuilt and restarted" +echo "" +echo "If the service is still failing, check the logs with:" +echo "docker compose logs git-integration" diff --git a/scripts/setup-git-repos-directories.sh b/scripts/setup-git-repos-directories.sh new file mode 100755 index 0000000..f06795d --- /dev/null +++ b/scripts/setup-git-repos-directories.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Script to create git-repos directories on the deployment server +# This fixes the EACCES permission denied error for git-integration service + +set -e + +echo "🔧 Setting up git-repos directories for deployment..." + +# Define the base directory +BASE_DIR="/home/ubuntu/codenuk-backend-live" +GIT_REPOS_DIR="$BASE_DIR/git-repos" +DIFFS_DIR="$GIT_REPOS_DIR/diffs" + +# Create directories if they don't exist +echo "📁 Creating directories..." +mkdir -p "$GIT_REPOS_DIR" +mkdir -p "$DIFFS_DIR" + +# Set proper ownership (UID 1001 matches the git-integration user in container) +echo "👤 Setting ownership to UID 1001 (git-integration user)..." +sudo chown -R 1001:1001 "$GIT_REPOS_DIR" + +# Set proper permissions +echo "🔒 Setting permissions..." +chmod -R 755 "$GIT_REPOS_DIR" + +# Verify the setup +echo "✅ Verifying setup..." +ls -la "$GIT_REPOS_DIR" + +echo "🎉 Git repos directories setup completed successfully!" +echo "📍 Base directory: $GIT_REPOS_DIR" +echo "📍 Diffs directory: $DIFFS_DIR" +echo "" +echo "Now you can run the deployment again:" +echo "docker compose up -d git-integration" diff --git a/services/git-integration/Dockerfile b/services/git-integration/Dockerfile index 6436956..a326aaa 100644 --- a/services/git-integration/Dockerfile +++ b/services/git-integration/Dockerfile @@ -25,12 +25,18 @@ RUN chmod -R 755 /app/git-repos # Create entrypoint script to handle volume permissions RUN echo '#!/bin/sh' > /app/entrypoint.sh && \ + echo '# Fix volume mount permissions' >> /app/entrypoint.sh && \ echo 'mkdir -p /app/git-repos/diffs' >> /app/entrypoint.sh && \ - echo 'chmod -R 755 /app/git-repos' >> /app/entrypoint.sh && \ - echo 'exec "$@"' >> /app/entrypoint.sh && \ + echo 'chown -R git-integration:nodejs /app/git-repos 2>/dev/null || true' >> /app/entrypoint.sh && \ + echo 'chmod -R 755 /app/git-repos 2>/dev/null || true' >> /app/entrypoint.sh && \ + echo '# Switch to git-integration user and execute command' >> /app/entrypoint.sh && \ + echo 'exec su-exec git-integration "$@"' >> /app/entrypoint.sh && \ chmod +x /app/entrypoint.sh -USER git-integration +# Install su-exec for user switching +RUN apk add --no-cache su-exec + +# Keep running as root for entrypoint, will switch to git-integration user in entrypoint # Expose port EXPOSE 8012