Remove unnecessary sections about cleanup
Some checks are pending
CI/CD Pipeline (Fully Isolated DinD) / Run Tests (DinD) (push) Waiting to run
CI/CD Pipeline (Fully Isolated DinD) / Build and Push Docker Images (DinD) (push) Blocked by required conditions
CI/CD Pipeline (Fully Isolated DinD) / Deploy to Production (push) Blocked by required conditions
Some checks are pending
CI/CD Pipeline (Fully Isolated DinD) / Run Tests (DinD) (push) Waiting to run
CI/CD Pipeline (Fully Isolated DinD) / Build and Push Docker Images (DinD) (push) Blocked by required conditions
CI/CD Pipeline (Fully Isolated DinD) / Deploy to Production (push) Blocked by required conditions
This commit is contained in:
parent
ce89117aa6
commit
117022cac6
1 changed files with 0 additions and 153 deletions
|
@ -1787,8 +1787,6 @@ curl http://localhost:3001/health
|
|||
|
||||
### Step 21: Configure Forgejo Repository Secrets
|
||||
|
||||
#### 21.1 Required Repository Secrets
|
||||
|
||||
Go to your Forgejo repository and add these secrets in **Settings → Secrets and Variables → Actions**:
|
||||
|
||||
**Required Secrets:**
|
||||
|
@ -1803,157 +1801,6 @@ Go to your Forgejo repository and add these secrets in **Settings → Secrets an
|
|||
- `DOMAIN`: Your domain name (e.g., `example.com`)
|
||||
- `EMAIL`: Your email for SSL certificate notifications
|
||||
|
||||
#### 21.2 Configure Forgejo Actions Runner
|
||||
|
||||
##### 21.2.1 Get Runner Token
|
||||
|
||||
1. Go to your Forgejo repository
|
||||
2. Navigate to **Settings → Actions → Runners**
|
||||
3. Click **"New runner"**
|
||||
4. Copy the registration token
|
||||
|
||||
##### 21.2.2 Configure Runner
|
||||
|
||||
```bash
|
||||
# Switch to DEPLOY_USER on CI/CD Linode
|
||||
sudo su - DEPLOY_USER
|
||||
|
||||
# Get the registration token from your Forgejo repository
|
||||
# Go to Settings → Actions → Runners → New runner
|
||||
# Copy the registration token
|
||||
|
||||
# Configure the runner
|
||||
forgejo-runner register \
|
||||
--instance https://your-forgejo-instance \
|
||||
--token YOUR_TOKEN \
|
||||
--name "ci-runner" \
|
||||
--labels "ci" \
|
||||
--no-interactive
|
||||
```
|
||||
|
||||
##### 21.2.3 Start Runner
|
||||
|
||||
```bash
|
||||
sudo systemctl start forgejo-runner.service
|
||||
sudo systemctl status forgejo-runner.service
|
||||
```
|
||||
|
||||
##### 21.2.4 Test Runner Configuration
|
||||
|
||||
```bash
|
||||
# Check if the runner is running
|
||||
sudo systemctl status forgejo-runner.service
|
||||
|
||||
# Check runner logs
|
||||
sudo journalctl -u forgejo-runner.service -f --no-pager
|
||||
|
||||
# Verify runner appears in Forgejo
|
||||
# Go to your Forgejo repository → Settings → Actions → Runners
|
||||
# You should see your runner listed as "ci-runner" with status "Online"
|
||||
```
|
||||
|
||||
**Expected Output**:
|
||||
- `systemctl status` should show "active (running)"
|
||||
- Forgejo web interface should show the runner as online with "ci" label
|
||||
|
||||
### Step 22: Set Up Monitoring and Cleanup
|
||||
|
||||
#### 22.1 Monitoring Script
|
||||
|
||||
**Important**: The repository includes a pre-configured monitoring script in the `scripts/` directory that can be used for both CI/CD and production monitoring.
|
||||
|
||||
**Repository Script**:
|
||||
- `scripts/monitor.sh` - Comprehensive monitoring script with support for both CI/CD and production environments
|
||||
|
||||
**To use the repository monitoring script**:
|
||||
```bash
|
||||
# The repository is already cloned at /opt/APP_NAME/
|
||||
cd /opt/APP_NAME
|
||||
|
||||
# Make the script executable
|
||||
chmod +x scripts/monitor.sh
|
||||
|
||||
# Test CI/CD monitoring
|
||||
./scripts/monitor.sh --type ci-cd
|
||||
|
||||
# Test production monitoring (if you have a production setup)
|
||||
./scripts/monitor.sh --type production
|
||||
```
|
||||
|
||||
**Note**: The repository script is more comprehensive and includes proper error handling, colored output, and support for both CI/CD and production environments. It automatically detects the environment and provides appropriate monitoring information.
|
||||
|
||||
#### 22.2 DinD Cleanup Script
|
||||
|
||||
**Important**: With the DinD setup, CI/CD operations are isolated in the DinD container. This means we can use a much simpler cleanup approach - just restart the DinD container for a fresh environment.
|
||||
|
||||
**DinD Cleanup Script**:
|
||||
- `scripts/dind-cleanup.sh` - Simple script to restart DinD container for fresh CI environment
|
||||
|
||||
**To use the DinD cleanup script**:
|
||||
```bash
|
||||
# The repository is already cloned at /opt/APP_NAME/
|
||||
cd /opt/APP_NAME
|
||||
|
||||
# Make the script executable
|
||||
chmod +x scripts/dind-cleanup.sh
|
||||
|
||||
# Test DinD cleanup (dry run first)
|
||||
./scripts/dind-cleanup.sh --dry-run
|
||||
|
||||
# Run DinD cleanup
|
||||
./scripts/dind-cleanup.sh
|
||||
```
|
||||
|
||||
**Benefits of DinD cleanup**:
|
||||
- ✅ **Simple operation**: Just restart the DinD container
|
||||
- ✅ **Zero Harbor impact**: Harbor registry is completely unaffected
|
||||
- ✅ **Fresh environment**: Every cleanup gives a completely clean state
|
||||
- ✅ **Fast execution**: No complex resource scanning needed
|
||||
- ✅ **Reliable**: No risk of accidentally removing Harbor resources
|
||||
|
||||
#### 22.3 Test DinD Cleanup Script
|
||||
|
||||
```bash
|
||||
# Test DinD cleanup with dry run first
|
||||
./scripts/dind-cleanup.sh --dry-run
|
||||
|
||||
# Run the DinD cleanup script
|
||||
./scripts/dind-cleanup.sh
|
||||
|
||||
# Verify DinD is working after cleanup
|
||||
docker exec ci-cd-dind docker version
|
||||
docker exec ci-cd-dind docker run --rm alpine:latest echo "DinD cleanup successful!"
|
||||
```
|
||||
|
||||
**Expected Output**:
|
||||
- DinD cleanup script should run without errors
|
||||
- DinD container should be restarted with fresh environment
|
||||
- Docker commands should work inside DinD after cleanup
|
||||
- Harbor registry should remain completely unaffected
|
||||
|
||||
**If something goes wrong**:
|
||||
- Check script permissions: `ls -la scripts/dind-cleanup.sh`
|
||||
- Verify DinD container: `docker ps | grep ci-cd-dind`
|
||||
- Check DinD logs: `docker logs ci-cd-dind`
|
||||
- Run manually: `bash -x scripts/dind-cleanup.sh`
|
||||
|
||||
#### 22.4 Set Up Automated DinD Cleanup
|
||||
|
||||
```bash
|
||||
# Create a cron job to run DinD cleanup daily at 2 AM
|
||||
(crontab -l 2>/dev/null; echo "0 2 * * * cd /opt/APP_NAME && ./scripts/dind-cleanup.sh >> /tmp/dind-cleanup.log 2>&1") | crontab -
|
||||
|
||||
# Verify the cron job was added
|
||||
crontab -l
|
||||
```
|
||||
|
||||
**What this does:**
|
||||
- **Runs automatically**: The DinD cleanup script runs every day at 2:00 AM
|
||||
- **Frequency**: Daily cleanup to prevent CI/CD resource buildup
|
||||
- **Logging**: All cleanup output is logged to `/tmp/dind-cleanup.log`
|
||||
- **What it cleans**: Restarts DinD container for fresh CI environment
|
||||
- **Zero Harbor impact**: Harbor registry operations are completely unaffected
|
||||
|
||||
### Step 22: Test Complete Pipeline
|
||||
|
||||
#### 22.1 Trigger a Test Build
|
||||
|
|
Loading…
Add table
Reference in a new issue