From 58b862debe66c3f9cee832414b4d5c3a28b64f61 Mon Sep 17 00:00:00 2001 From: continuist Date: Sat, 5 Jul 2025 12:55:45 -0400 Subject: [PATCH] Clone to a workspace folder on the host first --- .forgejo/workflows/ci.yml | 9 ++++----- CI_CD_PIPELINE_SETUP_GUIDE.md | 32 +++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index e4f3682..52b9c2b 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -66,16 +66,15 @@ jobs: - name: Checkout code to workspace run: | - # Create workspace directory - mkdir -p /workspace + # Use the pre-configured workspace directory (created in CI guide Step 7.3) # Clone the repository to workspace - git clone "${{ env.GITEA_SERVER_URL }}/${{ env.GITEA_REPOSITORY }}" /workspace - cd /workspace + git clone "${{ env.GITEA_SERVER_URL }}/${{ env.GITEA_REPOSITORY }}" /tmp/ci-workspace + cd /tmp/ci-workspace git checkout "${{ env.GITEA_SHA }}" # Copy workspace to DinD container - docker cp /workspace/. ci-dind:/workspace/ + docker cp /tmp/ci-workspace/. ci-dind:/workspace/ # Start testing environment using dedicated compose file inside DinD docker exec ci-dind docker compose -f /workspace/docker-compose.test.yml up -d diff --git a/CI_CD_PIPELINE_SETUP_GUIDE.md b/CI_CD_PIPELINE_SETUP_GUIDE.md index 8697198..84e6d66 100644 --- a/CI_CD_PIPELINE_SETUP_GUIDE.md +++ b/CI_CD_PIPELINE_SETUP_GUIDE.md @@ -1037,7 +1037,37 @@ docker exec ci-dind docker tag alpine:latest YOUR_CI_CD_IP/APP_NAME/test:latest docker exec ci-dind docker push YOUR_CI_CD_IP/APP_NAME/test:latest # Clean up test image -docker exec ci-dind docker rmi YOUR_CI_CD_IP/APP_NAME/test:latest +docker exec ci-dind docker rmi YOUR_CI_CD_IP/APP_NAME/test:latest + +#### 7.3 Set Up Workspace Directory + +**Important**: The CI workflow needs a workspace directory for code checkout. This directory will be used by the Forgejo Actions runner. + +```bash +# Switch to CI_DEPLOY_USER (who has sudo privileges) +sudo su - CI_DEPLOY_USER + +# Create workspace directory in /tmp with proper permissions +sudo mkdir -p /tmp/ci-workspace +sudo chown CI_SERVICE_USER:CI_SERVICE_USER /tmp/ci-workspace +sudo chmod 755 /tmp/ci-workspace + +# Verify the setup +ls -la /tmp/ci-workspace +``` + +**What this does**: +- **Creates workspace**: Provides a dedicated directory for CI operations +- **Proper ownership**: CI_SERVICE_USER owns the directory for write access +- **Appropriate permissions**: 755 allows read/write for owner, read for others +- **Temporary location**: Uses /tmp for easy cleanup and no persistence needed + +**Alternative locations** (if you prefer): +- `/opt/ci-workspace` - More permanent location +- `/home/CI_SERVICE_USER/workspace` - User's home directory +- `/var/lib/ci-workspace` - System-managed location + +**Note**: The CI workflow will use this directory for code checkout and then copy the contents to the DinD container. ``` **What this does**: