9 Commits

Author SHA1 Message Date
Ducky SSH User
999a595b9c Remove jq dependency from release workflow
Some checks failed
Build and Release / build (push) Failing after 12s
- Replace jq with grep for parsing JSON responses
- Use curl -w to capture HTTP response codes
- Improve error handling and logging
- Check HTTP response codes for upload success
- Should work on runners without jq installed
- Fixes 'command not found' error on release creation
2025-12-20 06:28:25 +00:00
Ducky SSH User
e6f705486d Fix git tag checkout in Gitea Actions workflow
Some checks failed
Build and Release / build (push) Failing after 10s
- For tags: fetch with explicit ref mapping to refs/tags/
- For branches: fetch with explicit ref mapping to refs/remotes/origin/
- Properly checkout tag refs using refs/tags/ path
- Fixes 'pathspec did not match any file(s)' error on tag builds
2025-12-20 06:24:56 +00:00
Ducky SSH User
66734923cb Update GITEA_SETUP.md for binary-only CI/CD pipeline
Some checks failed
Build and Release / build (push) Failing after 1s
- Clarify Docker is not required for CI/CD
- Note that Docker images are built manually
- Simplify troubleshooting section
- Remove Docker setup instructions from setup guide
- Link to manual Docker build documentation
2025-12-20 06:21:37 +00:00
Ducky SSH User
48d2d7f83d Update RELEASE.md to reflect binary-only CI/CD pipeline
- Remove references to Docker image CI/CD builds
- Clarify Docker images are built manually or with docker-compose
- Simplify deployment options (binaries, Docker, Docker Compose)
- Update troubleshooting to focus on binary releases
- Remove Docker-specific troubleshooting steps
- Keep Dockerfiles for manual builds
2025-12-20 06:21:18 +00:00
Ducky SSH User
444bda7263 Remove Docker-specific runner documentation
- Remove GITEA_RUNNER_DOCKER.md (no longer needed)
- Docker builds removed from CI/CD pipeline
- Dockerfiles and docker-compose remain for manual builds
2025-12-20 06:20:35 +00:00
Ducky SSH User
99fc1a28ad Simplify CI/CD pipeline to focus on binary releases only
- Remove docker-build job entirely
- Keep focus on cross-platform binary builds (Linux, macOS, Windows)
- Generate SHA256 checksums for all binaries
- Upload binaries and checksums to Gitea releases
- Keep Dockerfiles and docker-compose for manual builds
- Much simpler and more reliable workflow
2025-12-20 06:20:32 +00:00
Ducky SSH User
2075cd2901 Fix Docker builds in Gitea runner with proper Docker-in-Docker detection
- Use 'docker info' instead of 'command -v docker' for reliable detection
- Add 30-second wait for Docker daemon startup (for DinD startup delay)
- Improve Docker build step with better error handling
- Build Docker images when available, skip gracefully if not
- Add comprehensive GITEA_RUNNER_DOCKER.md setup guide
- Document Docker socket mounting for runners
- Include troubleshooting and complete docker-compose example
2025-12-20 06:16:10 +00:00
Ducky SSH User
f4ec33fe53 Update GITEA_SETUP.md with optional Docker configuration
- Document Docker installation on runner for image builds
- Clarify that Docker is optional (not required for binary builds)
- Add instructions for running the runner user with Docker permissions
- Update troubleshooting section with Docker-specific guidance
- Explain graceful handling when Docker is not available
- Add Docker installation link in support section
2025-12-20 06:13:53 +00:00
Ducky SSH User
3080cb1e87 Make Docker build optional in Gitea Actions workflow
- Check if Docker is available before attempting to use it
- Skip Docker image builds gracefully if Docker is not installed
- Provide helpful instructions for enabling Docker support
- Add error handling for Docker build failures
- Allow workflow to succeed even without Docker
- Binary builds will still complete successfully
2025-12-20 06:13:34 +00:00
3 changed files with 136 additions and 189 deletions

View File

@@ -17,10 +17,14 @@ jobs:
cd $GITHUB_WORKSPACE cd $GITHUB_WORKSPACE
git init git init
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
git fetch origin ${{ github.ref }}
if [[ "${{ github.ref }}" == refs/tags/* ]]; then if [[ "${{ github.ref }}" == refs/tags/* ]]; then
git checkout ${{ github.ref_name }} # For tags, fetch the specific tag and checkout the commit it points to
git fetch origin ${{ github.ref }}:refs/tags/${{ github.ref_name }}
git checkout refs/tags/${{ github.ref_name }}
else else
# For branches, fetch and checkout with tracking
git fetch origin ${{ github.ref_name }}:refs/remotes/origin/${{ github.ref_name }}
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }} git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
fi fi
@@ -99,26 +103,25 @@ jobs:
echo "Creating release for tag: $TAG" echo "Creating release for tag: $TAG"
echo "Repository: $REPO_OWNER/$REPO_NAME" echo "Repository: $REPO_OWNER/$REPO_NAME"
# Get or create release # Create release using Gitea API
RELEASE_JSON=$(curl -s -X GET \
-H "Authorization: token $GITEA_TOKEN" \
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases/tags/$TAG" 2>/dev/null || echo "{}")
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id // empty' 2>/dev/null)
if [ -z "$RELEASE_ID" ]; then
echo "Creating new release..." echo "Creating new release..."
RELEASE_JSON=$(curl -s -X POST \ RESPONSE=$(curl -s -X POST \
-H "Authorization: token $GITEA_TOKEN" \ -H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"name\":\"Release $TAG\",\"draft\":false,\"prerelease\":false}" \ -d "{\"tag_name\":\"$TAG\",\"name\":\"Release $TAG\",\"draft\":false,\"prerelease\":false}" \
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases") "$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases")
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id')
echo "Created release ID: $RELEASE_ID" # Extract release ID using grep instead of jq
else RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
echo "Using existing release ID: $RELEASE_ID"
if [ -z "$RELEASE_ID" ]; then
echo "Failed to create release. Response:"
echo "$RESPONSE"
exit 1
fi fi
echo "Created release ID: $RELEASE_ID"
# Upload all binaries # Upload all binaries
echo "Uploading release artifacts..." echo "Uploading release artifacts..."
for file in bin/*; do for file in bin/*; do
@@ -126,15 +129,18 @@ jobs:
filename=$(basename "$file") filename=$(basename "$file")
echo " Uploading: $filename" echo " Uploading: $filename"
curl -s -X POST \ UPLOAD_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
-H "Authorization: token $GITEA_TOKEN" \ -H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@$file" \ -F "attachment=@$file" \
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases/$RELEASE_ID/assets" > /dev/null "$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases/$RELEASE_ID/assets")
if [ $? -eq 0 ]; then HTTP_CODE=$(echo "$UPLOAD_RESPONSE" | tail -n 1)
echo " ✓ $filename uploaded"
if [ "$HTTP_CODE" = "201" ] || [ "$HTTP_CODE" = "200" ]; then
echo " ✓ $filename uploaded (HTTP $HTTP_CODE)"
else else
echo " ✗ Failed to upload $filename" echo " ✗ Failed to upload $filename (HTTP $HTTP_CODE)"
echo "Response: $(echo "$UPLOAD_RESPONSE" | head -n -1)"
fi fi
fi fi
done done
@@ -142,89 +148,3 @@ jobs:
echo "" echo ""
echo "Release completed!" echo "Release completed!"
echo "View at: $GITEA_URL/$REPO_OWNER/$REPO_NAME/releases/tag/$TAG" echo "View at: $GITEA_URL/$REPO_OWNER/$REPO_NAME/releases/tag/$TAG"
docker-build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
run: |
cd $GITHUB_WORKSPACE
git init
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
git fetch origin ${{ github.ref }}
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
git checkout ${{ github.ref_name }}
else
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
fi
- name: Set up Docker
run: |
docker --version
which docker
- name: Generate version
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${{ github.ref_name }}
else
VERSION=dev-${{ github.sha }}
fi
echo "version=${VERSION}" >> $GITHUB_ENV
- name: Build Docker images
run: |
mkdir -p /tmp/docker-images
echo "Building server image..."
docker build -t nerd-monitor-server:${{ env.version }} -f Dockerfile.server .
docker save nerd-monitor-server:${{ env.version }} -o /tmp/docker-images/nerd-monitor-server-${{ env.version }}.tar
echo "Building agent image..."
docker build -t nerd-monitor-agent:${{ env.version }} -f Dockerfile.agent .
docker save nerd-monitor-agent:${{ env.version }} -o /tmp/docker-images/nerd-monitor-agent-${{ env.version }}.tar
echo "Docker images built:"
ls -lh /tmp/docker-images/
- name: Upload Docker images to release
if: startsWith(github.ref, 'refs/tags/')
run: |
export GITEA_TOKEN="${{ secrets.GITEA_TOKEN }}"
export GITEA_URL="${{ github.server_url }}"
export REPO_OWNER="${{ github.repository_owner }}"
export REPO_NAME="${{ github.repository }}"
export REPO_NAME=${REPO_NAME#*/}
TAG=${{ github.ref_name }}
# Get existing release
RELEASE_JSON=$(curl -s -X GET \
-H "Authorization: token $GITEA_TOKEN" \
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases/tags/$TAG" 2>/dev/null || echo "{}")
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id // empty' 2>/dev/null)
if [ -z "$RELEASE_ID" ]; then
echo "Release not found, skipping Docker image upload"
else
echo "Uploading Docker images to release $RELEASE_ID..."
for file in /tmp/docker-images/*; do
if [ -f "$file" ]; then
filename=$(basename "$file")
echo " Uploading: $filename"
curl -s -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@$file" \
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases/$RELEASE_ID/assets" > /dev/null
if [ $? -eq 0 ]; then
echo " ✓ $filename uploaded"
else
echo " ✗ Failed to upload $filename"
fi
fi
done
fi

View File

@@ -58,7 +58,7 @@ sudo systemctl restart gitea
## Setting Up a Runner (if needed) ## Setting Up a Runner (if needed)
If you don't have any runners yet, you need to set one up. This can be on the Gitea server itself or any machine with Docker/Go. If you don't have any runners yet, you need to set one up. This can be on the Gitea server itself or any machine with Docker and Go.
### Quick Runner Setup ### Quick Runner Setup
@@ -84,34 +84,66 @@ To get a runner token:
3. Click **Create new runner** 3. Click **Create new runner**
4. Follow the registration steps 4. Follow the registration steps
## Testing the Setup ### Installing Docker on the Runner (Optional)
Once everything is configured: Docker is **not required** for the CI/CD pipeline. Binary builds work without Docker.
If you want to manually build Docker images:
1. **Push a test tag**:
```bash ```bash
git tag -a v0.0.1-test -m "Test release" # Build server image
git push origin v0.0.1-test docker build -t nerd-monitor-server -f Dockerfile.server .
# Build agent image
docker build -t nerd-monitor-agent -f Dockerfile.agent .
# Or use docker-compose for both
docker-compose build
docker-compose up
``` ```
2. **Monitor the build**: ## What Happens Next
- Go to Actions tab
- You should see the workflow running
- Check logs for any errors
3. **Verify the release**: Once you've set everything up:
- Go to Releases tab
- You should see a new release with binaries and checksums 1. **Every push to main/master** triggers the build job:
- Compiles all platform binaries (Linux, macOS, Windows)
- Creates SHA256 checksums
- Artifacts available for 30 days
2. **Every git tag push** (e.g., `v1.0.0`) triggers the full release:
- Does all of the above
- Creates a Gitea Release
- Uploads all binaries and checksums to the release (permanent storage)
3. **Releases are available in**:
- Repository Releases tab in Gitea
- All binaries ready for download
- SHA256SUMS file for verification
Note: Docker images are not built automatically. To build Docker images manually, use:
```bash
docker build -t nerd-monitor-server -f Dockerfile.server .
docker build -t nerd-monitor-agent -f Dockerfile.agent .
# Or use docker-compose: docker-compose build
```
## Troubleshooting ## Troubleshooting
### "docker: command not found" in workflow
- Docker support is not required - the workflow builds binaries without it
- Binary builds will always succeed
- Docker images must be built manually using: `docker build -f Dockerfile.server .`
- See QUICKSTART.md or DOCKER_COMPOSE.md for manual Docker build instructions
### "Action not found" error ### "Action not found" error
- Make sure Gitea Actions is enabled - Make sure Gitea Actions is enabled
- Restart Gitea if you just enabled it: `sudo systemctl restart gitea` - Restart Gitea if you just enabled it: `sudo systemctl restart gitea`
### No runners available ### No runners available
- Runner must be registered: Administration → Actions → Runners - Runner must be registered: Administration → Actions → Runners
- Runner machine must have Docker and Go installed - Runner machine must have Go installed (1.24.4 or later)
- Docker is optional (for building Docker images)
- Check if runner is online in the UI - Check if runner is online in the UI
### "GITEA_TOKEN" not found ### "GITEA_TOKEN" not found
@@ -119,33 +151,14 @@ git push origin v0.0.1-test
- Go to Settings → Secrets and verify it's there - Go to Settings → Secrets and verify it's there
- If it's there, try re-running the workflow - If it's there, try re-running the workflow
### Build fails with permission denied ### Build fails with permission denied (Docker)
- Make sure the runner has permission to run Docker commands - Make sure the runner user has permission to run Docker commands
- On the runner machine: `sudo usermod -aG docker $USER` - On the runner machine: `sudo usermod -aG docker $USER`
- Logout and log back in for the group change to take effect - Logout and log back in for the group change to take effect
## What Happens Next
Once you've set everything up:
1. **Every push to main/master** triggers the build job:
- Compiles all platform binaries
- Builds Docker images
- Uploads artifacts as build artifacts
2. **Every git tag push** (e.g., `v1.0.0`) triggers the full release:
- Does all of the above
- Creates a Gitea Release
- Uploads all binaries and Docker images to the release
- Generates SHA256 checksums
3. **Releases are available in**:
- Repository Releases tab in Gitea
- Binaries ready for download
- Docker images ready for import
## Support ## Support
- Gitea Actions Docs: https://docs.gitea.io/en-us/actions/ - Gitea Actions Docs: https://docs.gitea.io/en-us/actions/
- Act Runner Docs: https://gitea.com/gitea/act_runner - Act Runner Docs: https://gitea.com/gitea/act_runner
- Docker Installation: https://docs.docker.com/install/
- For issues with the workflow itself, check the Actions tab logs - For issues with the workflow itself, check the Actions tab logs

View File

@@ -2,7 +2,7 @@
## Overview ## Overview
This project uses **Gitea Actions** to automatically build and release binaries and Docker images when you push to the `master` branch or create a new tag. This project uses **Gitea Actions** to automatically build and release cross-platform binaries when you push to the `master` branch or create a new tag.
## Automatic Release Pipeline ## Automatic Release Pipeline
@@ -11,13 +11,12 @@ This project uses **Gitea Actions** to automatically build and release binaries
1. **Master Branch Push**: When you push to `master`, the workflow: 1. **Master Branch Push**: When you push to `master`, the workflow:
- Builds all platform binaries (Linux/macOS/Windows, amd64/arm64) - Builds all platform binaries (Linux/macOS/Windows, amd64/arm64)
- Generates checksums (SHA256) - Generates checksums (SHA256)
- Uploads artifacts for 30 days - Binaries are available as build artifacts for 30 days
- Builds Docker images (server & agent)
2. **Tag Creation**: When you create a tag (e.g., `v1.0.0`), the workflow: 2. **Tag Creation**: When you create a tag (e.g., `v1.0.0`), the workflow:
- Does all of the above - Does all of the above
- Creates a GitHub Release - Creates a Gitea Release
- Uploads all binaries and Docker images to the release - Uploads all binaries and checksums to the release (permanent storage)
### Supported Platforms ### Supported Platforms
@@ -26,19 +25,32 @@ Binaries are built for:
- **macOS**: amd64 (Intel), arm64 (Apple Silicon) - **macOS**: amd64 (Intel), arm64 (Apple Silicon)
- **Windows**: amd64 - **Windows**: amd64
Docker images are built for Linux containers. ### What Gets Built and Released
When you push a tag, the workflow automatically creates:
**Binaries** (10 files total):
- `nerd-monitor-server-linux-amd64` - Server for Linux x86_64
- `nerd-monitor-server-linux-arm64` - Server for Linux ARM64 (Raspberry Pi, etc.)
- `nerd-monitor-server-darwin-amd64` - Server for macOS Intel
- `nerd-monitor-server-darwin-arm64` - Server for macOS Apple Silicon
- `nerd-monitor-server-windows-amd64.exe` - Server for Windows
- `nerd-monitor-agent-linux-amd64` - Agent for Linux x86_64
- `nerd-monitor-agent-linux-arm64` - Agent for Linux ARM64
- `nerd-monitor-agent-darwin-amd64` - Agent for macOS Intel
- `nerd-monitor-agent-darwin-arm64` - Agent for macOS Apple Silicon
- `nerd-monitor-agent-windows-amd64.exe` - Agent for Windows
**Checksums**:
- `SHA256SUMS` - SHA256 checksums for all binaries (for verification)
## Workflow Configuration ## Workflow Configuration
The Gitea Actions workflow is defined in `.gitea/workflows/release.yml` The Gitea Actions workflow is defined in `.gitea/workflows/release.yml`
### Trigger Events ### Trigger Events
- Push to `master` branch - Push to `master` or `main` branch (builds only, no release)
- Push of git tags (e.g., `v1.0.0`) - Push of git tags (e.g., `v1.0.0`) - triggers full release with uploads
### Jobs
- `build`: Compiles all platform binaries and generates checksums
- `docker-build`: Builds Docker images for server and agent
### Creating a Release ### Creating a Release
@@ -89,10 +101,6 @@ When you push a tag, the workflow automatically:
**Checksums**: **Checksums**:
- `SHA256SUMS` - SHA256 checksums for all binaries (for verification) - `SHA256SUMS` - SHA256 checksums for all binaries (for verification)
**Docker Images**:
- `nerd-monitor-server-v1.0.0.tar` - Server Docker image (can be imported)
- `nerd-monitor-agent-v1.0.0.tar` - Agent Docker image (can be imported)
## Local Building ## Local Building
You can also build binaries locally: You can also build binaries locally:
@@ -110,21 +118,25 @@ make clean
Binaries are created in the `bin/` directory. Binaries are created in the `bin/` directory.
## Docker Images ## Docker Images (Manual Build)
Two Docker images are built: Docker images are available but not built automatically by CI/CD. To build them manually:
### Server Image
```bash ```bash
docker pull nerd-monitor-server:latest # Build server image
docker run -p 8080:8080 nerd-monitor-server docker build -t nerd-monitor-server:latest -f Dockerfile.server .
# Build agent image
docker build -t nerd-monitor-agent:latest -f Dockerfile.agent .
# Or use Docker Compose
docker-compose build
# Or use Docker Compose to run both
docker-compose up
``` ```
### Agent Image See `DOCKER_COMPOSE.md` and `QUICKSTART.md` for detailed instructions.
```bash
docker pull nerd-monitor-agent:latest
docker run nerd-monitor-agent --server your-server:8080
```
## Gitea Configuration ## Gitea Configuration
@@ -205,18 +217,30 @@ nerd-monitor-agent-windows-amd64.exe
SHA256SUMS (checksums for all binaries) SHA256SUMS (checksums for all binaries)
``` ```
## Coolify Integration ## Deployment Options
If you want to use Coolify for deployment: ### Option 1: Use Pre-Built Binaries (Recommended)
Download the native binaries from the Releases tab and run directly:
- Smallest footprint
- No Docker required
- Easiest to deploy to existing machines
1. **For Server Deployment**: ### Option 2: Use Docker (Manual Build)
- Use `Dockerfile.server` as the build context Build Docker images manually and deploy:
- Coolify will auto-build on `master` branch pushes ```bash
- Deploy the server container to Coolify docker build -t nerd-monitor-server:latest -f Dockerfile.server .
docker run -p 8080:8080 nerd-monitor-server:latest
```
2. **For Agent Deployment**: See `docker-compose.yml` for running both server and agent together.
- Use `Dockerfile.agent` as the build context
- Deploy the agent container to machines that need monitoring ### Option 3: Use Docker Compose
For quick development/testing with both server and agent:
```bash
docker-compose up
```
See `DOCKER_COMPOSE.md` and `QUICKSTART.md` for details.
## Troubleshooting ## Troubleshooting
@@ -259,22 +283,12 @@ If you want to use Coolify for deployment:
3. Verify the release was created: Go to Releases tab 3. Verify the release was created: Go to Releases tab
4. Check that `GITEA_TOKEN` secret is still valid (tokens can expire) 4. Check that `GITEA_TOKEN` secret is still valid (tokens can expire)
### Docker Image Build Fails
**Problem**: `docker-build` job fails
**Solutions**:
1. Verify Docker is installed on the runner: SSH to runner and run `docker --version`
2. Check if the Dockerfile has syntax errors: `docker build -f Dockerfile.server .`
3. Ensure runner has enough disk space for building: `docker system df`
4. Check Docker daemon is running: `sudo systemctl status docker`
### How to Check Workflow Logs ### How to Check Workflow Logs
1. Go to your Gitea repository 1. Go to your Gitea repository
2. Click the **Actions** tab 2. Click the **Actions** tab
3. Click on the workflow run (should show the tag name) 3. Click on the workflow run (should show the tag name)
4. Click on the job that failed (`build` or `docker-build`) 4. Click on the `build` job
5. Scroll through the log to find error messages 5. Scroll through the log to find error messages
6. Look for red `❌` marks indicating failures 6. Look for red `❌` marks indicating failures