Compare commits
7 Commits
9bd0c16a90
...
v0.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89fb5bbf7d | ||
|
|
6c6bc0d57f | ||
|
|
3dbd60ac27 | ||
|
|
5664105111 | ||
|
|
b87c61ea99 | ||
|
|
98ecc61624 | ||
|
|
9184de0a1d |
59
.coolify
59
.coolify
@@ -1,59 +0,0 @@
|
|||||||
# Nerd Monitor - Coolify Configuration
|
|
||||||
# This file documents the Coolify setup for Nerd Monitor
|
|
||||||
|
|
||||||
# Build Pack: Dockerfile (Custom)
|
|
||||||
# The project includes a Dockerfile optimized for Coolify
|
|
||||||
|
|
||||||
# Build Configuration:
|
|
||||||
# - Base Image: golang:1.23-alpine (builder), alpine:latest (runtime)
|
|
||||||
# - Build Context: . (repository root)
|
|
||||||
# - Dockerfile: ./Dockerfile
|
|
||||||
|
|
||||||
# Ports
|
|
||||||
# - Internal: 8080
|
|
||||||
# - External: 8080 (configurable in Coolify UI)
|
|
||||||
|
|
||||||
# Environment Variables (set in Coolify):
|
|
||||||
# ADDR=0.0.0.0
|
|
||||||
# PORT=8080
|
|
||||||
# USERNAME=admin (change in production)
|
|
||||||
# PASSWORD=admin (change in production)
|
|
||||||
|
|
||||||
# Health Check: Enabled
|
|
||||||
# - Endpoint: http://localhost:8080/login
|
|
||||||
# - Interval: 30s
|
|
||||||
# - Timeout: 3s
|
|
||||||
# - Retries: 3
|
|
||||||
# - Start Period: 5s
|
|
||||||
|
|
||||||
# Auto-Deploy on Push:
|
|
||||||
# 1. Connect repository to Coolify (Gitea)
|
|
||||||
# 2. Set branch to: master
|
|
||||||
# 3. Enable auto-deploy on push
|
|
||||||
# 4. Coolify will automatically build on every push to master
|
|
||||||
|
|
||||||
# Build Optimization:
|
|
||||||
# - Multi-stage build reduces final image size
|
|
||||||
# - Alpine-based for minimal footprint (~40MB final image)
|
|
||||||
# - Non-root user for security
|
|
||||||
# - Strip binaries (-w -s flags) to reduce size
|
|
||||||
|
|
||||||
# CI/CD Pipeline Flow:
|
|
||||||
# Push to master → Gitea webhook → Coolify detects
|
|
||||||
# → Coolify builds Dockerfile → New image created
|
|
||||||
# → Coolify deploys container → Service available
|
|
||||||
|
|
||||||
# Related Files:
|
|
||||||
# - Dockerfile: Server container definition
|
|
||||||
# - Dockerfile.agent: Agent container definition
|
|
||||||
# - docker-compose.yml: Local development setup
|
|
||||||
# - .dockerignore: Files excluded from Docker build context
|
|
||||||
|
|
||||||
# For local testing before pushing:
|
|
||||||
# docker-compose up -d
|
|
||||||
|
|
||||||
# For production deployment via Coolify:
|
|
||||||
# 1. Set USERNAME and PASSWORD in Coolify environment variables
|
|
||||||
# 2. Configure domain/SSL if needed
|
|
||||||
# 3. Set resource limits (CPU, Memory)
|
|
||||||
# 4. Configure auto-scaling if needed
|
|
||||||
@@ -1,54 +1,39 @@
|
|||||||
# Git
|
# Git
|
||||||
.git
|
.git
|
||||||
.gitignore
|
.gitignore
|
||||||
.gitmodules
|
.gitattributes
|
||||||
|
|
||||||
# Build artifacts
|
# Development
|
||||||
bin/
|
.vscode
|
||||||
dist/
|
.idea
|
||||||
*.exe
|
|
||||||
*.dll
|
|
||||||
*.so
|
|
||||||
*.dylib
|
|
||||||
|
|
||||||
# Generated code
|
|
||||||
views/*_templ.go
|
|
||||||
|
|
||||||
# IDE
|
|
||||||
.vscode/
|
|
||||||
.idea/
|
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
*~
|
*~
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*.iml
|
|
||||||
|
|
||||||
# Go
|
# Build artifacts
|
||||||
|
bin/
|
||||||
|
dist/
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
vendor/
|
vendor/
|
||||||
.env
|
|
||||||
.env.local
|
|
||||||
*.test
|
|
||||||
|
|
||||||
# OS
|
|
||||||
Thumbs.db
|
|
||||||
.DS_Store
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# Docker
|
|
||||||
Dockerfile
|
|
||||||
docker-compose.yml
|
|
||||||
.dockerignore
|
|
||||||
|
|
||||||
# CI/CD
|
|
||||||
.github/
|
|
||||||
.gitlab-ci.yml
|
|
||||||
.circleci/
|
|
||||||
|
|
||||||
# Node (if added in future)
|
|
||||||
node_modules/
|
|
||||||
package-lock.json
|
|
||||||
yarn.lock
|
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
*.md
|
*.md
|
||||||
CHANGELOG
|
RELEASE.md
|
||||||
|
README.md
|
||||||
|
QUICKSTART.md
|
||||||
|
AGENTS.md
|
||||||
|
|
||||||
|
# Other
|
||||||
|
docker-compose.yml
|
||||||
|
Dockerfile
|
||||||
|
Dockerfile.server
|
||||||
|
Dockerfile.agent
|
||||||
|
.dockerignore
|
||||||
|
.github
|
||||||
|
.gitea
|
||||||
|
scripts/
|
||||||
|
|||||||
230
.gitea/workflows/release.yml
Normal file
230
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
name: Build and Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
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 Go
|
||||||
|
run: |
|
||||||
|
wget https://go.dev/dl/go1.24.4.linux-amd64.tar.gz
|
||||||
|
tar -C /usr/local -xzf go1.24.4.linux-amd64.tar.gz
|
||||||
|
export PATH=$PATH:/usr/local/go/bin
|
||||||
|
go version
|
||||||
|
|
||||||
|
- 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 all binaries
|
||||||
|
run: |
|
||||||
|
export PATH=$PATH:/usr/local/go/bin
|
||||||
|
mkdir -p bin
|
||||||
|
|
||||||
|
# Generate templ first
|
||||||
|
go run github.com/a-h/templ/cmd/templ@latest generate
|
||||||
|
|
||||||
|
# Linux AMD64
|
||||||
|
echo "Building Linux AMD64..."
|
||||||
|
GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-server-linux-amd64 ./cmd/server
|
||||||
|
GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-agent-linux-amd64 ./cmd/agent
|
||||||
|
|
||||||
|
# Linux ARM64
|
||||||
|
echo "Building Linux ARM64..."
|
||||||
|
GOOS=linux GOARCH=arm64 go build -ldflags="-w -s" -o bin/nerd-monitor-server-linux-arm64 ./cmd/server
|
||||||
|
GOOS=linux GOARCH=arm64 go build -ldflags="-w -s" -o bin/nerd-monitor-agent-linux-arm64 ./cmd/agent
|
||||||
|
|
||||||
|
# macOS AMD64
|
||||||
|
echo "Building macOS AMD64..."
|
||||||
|
GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-server-darwin-amd64 ./cmd/server
|
||||||
|
GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-agent-darwin-amd64 ./cmd/agent
|
||||||
|
|
||||||
|
# macOS ARM64
|
||||||
|
echo "Building macOS ARM64..."
|
||||||
|
GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o bin/nerd-monitor-server-darwin-arm64 ./cmd/server
|
||||||
|
GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o bin/nerd-monitor-agent-darwin-arm64 ./cmd/agent
|
||||||
|
|
||||||
|
# Windows AMD64
|
||||||
|
echo "Building Windows AMD64..."
|
||||||
|
GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-server-windows-amd64.exe ./cmd/server
|
||||||
|
GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-agent-windows-amd64.exe ./cmd/agent
|
||||||
|
|
||||||
|
echo "Build complete! Files:"
|
||||||
|
ls -lh bin/
|
||||||
|
|
||||||
|
- name: Create checksums
|
||||||
|
run: |
|
||||||
|
cd bin
|
||||||
|
sha256sum * > SHA256SUMS
|
||||||
|
cd ..
|
||||||
|
echo "Checksums:"
|
||||||
|
cat bin/SHA256SUMS
|
||||||
|
|
||||||
|
- name: Create Release and Upload
|
||||||
|
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 }}
|
||||||
|
|
||||||
|
echo "Creating release for tag: $TAG"
|
||||||
|
echo "Repository: $REPO_OWNER/$REPO_NAME"
|
||||||
|
|
||||||
|
# Get or create 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 "Creating new release..."
|
||||||
|
RELEASE_JSON=$(curl -s -X POST \
|
||||||
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"Release $TAG\",\"draft\":false,\"prerelease\":false}" \
|
||||||
|
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases")
|
||||||
|
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id')
|
||||||
|
echo "Created release ID: $RELEASE_ID"
|
||||||
|
else
|
||||||
|
echo "Using existing release ID: $RELEASE_ID"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Upload all binaries
|
||||||
|
echo "Uploading release artifacts..."
|
||||||
|
for file in bin/*; 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
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Release completed!"
|
||||||
|
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
|
||||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -31,8 +31,3 @@ Thumbs.db
|
|||||||
# Local configuration
|
# Local configuration
|
||||||
config.local.yaml
|
config.local.yaml
|
||||||
.env.*.local
|
.env.*.local
|
||||||
|
|
||||||
# Docker volumes/containers (local development)
|
|
||||||
# Note: Keep Dockerfile, Dockerfile.agent, docker-compose.yml, and .dockerignore in git
|
|
||||||
docker-volumes/
|
|
||||||
*.tar.gz
|
|
||||||
|
|||||||
365
DOCKER.md
365
DOCKER.md
@@ -1,365 +0,0 @@
|
|||||||
# Docker & Coolify Deployment Guide
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
Nerd Monitor is optimized for containerized deployment using Docker and Coolify CI/CD. This guide covers setup with Coolify, local development with Docker Compose, and deployment options.
|
|
||||||
|
|
||||||
## Quick Start with Coolify
|
|
||||||
|
|
||||||
### Prerequisites
|
|
||||||
- Gitea repository configured
|
|
||||||
- Coolify instance running
|
|
||||||
- Docker/container runtime available
|
|
||||||
|
|
||||||
### Setup Steps
|
|
||||||
|
|
||||||
1. **Connect Repository to Coolify**
|
|
||||||
- In Coolify, add new application
|
|
||||||
- Select "Git Repository"
|
|
||||||
- Choose your Gitea instance
|
|
||||||
- Select `nerd-monitor` repository
|
|
||||||
|
|
||||||
2. **Configure Build Settings**
|
|
||||||
- **Build Pack**: Dockerfile
|
|
||||||
- **Dockerfile Path**: `./Dockerfile`
|
|
||||||
- **Build Context**: `.` (root)
|
|
||||||
- **Docker Image**: `nerd-monitor-server:latest`
|
|
||||||
|
|
||||||
3. **Set Environment Variables**
|
|
||||||
In Coolify environment configuration:
|
|
||||||
```
|
|
||||||
ADDR=0.0.0.0
|
|
||||||
PORT=8080
|
|
||||||
USERNAME=admin
|
|
||||||
PASSWORD=secure_password_here
|
|
||||||
```
|
|
||||||
|
|
||||||
4. **Enable Auto-Deploy**
|
|
||||||
- Set **Watch** to: `master`
|
|
||||||
- Enable **Auto-deploy on push**
|
|
||||||
- Coolify will automatically build and deploy on every push to master
|
|
||||||
|
|
||||||
5. **Configure Ports**
|
|
||||||
- **Container Port**: 8080
|
|
||||||
- **Public Port**: 8080 (or as needed)
|
|
||||||
- **Protocol**: HTTP/HTTPS
|
|
||||||
|
|
||||||
6. **Set Resource Limits** (optional)
|
|
||||||
- CPU: 500m - 1000m
|
|
||||||
- Memory: 256MB - 512MB
|
|
||||||
|
|
||||||
## Docker Files Included
|
|
||||||
|
|
||||||
### Dockerfile
|
|
||||||
- **Purpose**: Multi-stage build for the server
|
|
||||||
- **Base Image**: Alpine (lightweight)
|
|
||||||
- **Final Size**: ~40MB
|
|
||||||
- **User**: Non-root (nerdmonitor)
|
|
||||||
- **Health Check**: Enabled
|
|
||||||
|
|
||||||
### Dockerfile.agent
|
|
||||||
- **Purpose**: Container for agent deployment
|
|
||||||
- **Use Case**: Running agents in containerized environments
|
|
||||||
- **Base Image**: Alpine
|
|
||||||
- **Size**: ~15MB
|
|
||||||
|
|
||||||
### docker-compose.yml
|
|
||||||
- **Purpose**: Local development and testing
|
|
||||||
- **Services**: Server + Demo Agent
|
|
||||||
- **Network**: Bridged (isolated)
|
|
||||||
- **Volume**: Logs persistence
|
|
||||||
|
|
||||||
### .dockerignore
|
|
||||||
- **Purpose**: Optimize build context
|
|
||||||
- **Excludes**: Git files, IDE configs, documentation
|
|
||||||
- **Benefit**: Faster builds, smaller context
|
|
||||||
|
|
||||||
## Local Development
|
|
||||||
|
|
||||||
### Using Docker Compose
|
|
||||||
|
|
||||||
Start the full stack locally:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Build and start all services
|
|
||||||
docker-compose up -d
|
|
||||||
|
|
||||||
# View logs
|
|
||||||
docker-compose logs -f server
|
|
||||||
|
|
||||||
# Stop all services
|
|
||||||
docker-compose down
|
|
||||||
|
|
||||||
# Remove volumes (clean slate)
|
|
||||||
docker-compose down -v
|
|
||||||
```
|
|
||||||
|
|
||||||
Access dashboard:
|
|
||||||
- URL: http://localhost:8080
|
|
||||||
- Username: admin
|
|
||||||
- Password: admin
|
|
||||||
|
|
||||||
### Manual Docker Commands
|
|
||||||
|
|
||||||
Build server image:
|
|
||||||
```bash
|
|
||||||
docker build -t nerd-monitor-server:latest -f Dockerfile .
|
|
||||||
```
|
|
||||||
|
|
||||||
Run server container:
|
|
||||||
```bash
|
|
||||||
docker run -d \
|
|
||||||
--name nerd-monitor-server \
|
|
||||||
-p 8080:8080 \
|
|
||||||
-e USERNAME=admin \
|
|
||||||
-e PASSWORD=admin \
|
|
||||||
nerd-monitor-server:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
Build agent image:
|
|
||||||
```bash
|
|
||||||
docker build -t nerd-monitor-agent:latest -f Dockerfile.agent .
|
|
||||||
```
|
|
||||||
|
|
||||||
Run agent container:
|
|
||||||
```bash
|
|
||||||
docker run -d \
|
|
||||||
--name nerd-monitor-agent \
|
|
||||||
-e SERVER=server-ip:8080 \
|
|
||||||
nerd-monitor-agent:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
## Coolify Deployment Flow
|
|
||||||
|
|
||||||
```
|
|
||||||
┌─────────────────┐
|
|
||||||
│ Push to master │
|
|
||||||
│ (Git commit) │
|
|
||||||
└────────┬────────┘
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
┌─────────────────────┐
|
|
||||||
│ Gitea Webhook │
|
|
||||||
│ notifies Coolify │
|
|
||||||
└────────┬────────────┘
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
┌─────────────────────┐
|
|
||||||
│ Coolify receives │
|
|
||||||
│ build trigger │
|
|
||||||
└────────┬────────────┘
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
┌─────────────────────┐
|
|
||||||
│ Coolify clones │
|
|
||||||
│ repository │
|
|
||||||
└────────┬────────────┘
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
┌─────────────────────┐
|
|
||||||
│ Docker build │
|
|
||||||
│ executes Dockerfile│
|
|
||||||
└────────┬────────────┘
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
┌─────────────────────┐
|
|
||||||
│ Multi-stage build: │
|
|
||||||
│ 1. Build binaries │
|
|
||||||
│ 2. Create runtime │
|
|
||||||
└────────┬────────────┘
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
┌─────────────────────┐
|
|
||||||
│ Image pushed to │
|
|
||||||
│ registry (local) │
|
|
||||||
└────────┬────────────┘
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
┌─────────────────────┐
|
|
||||||
│ Coolify stops old │
|
|
||||||
│ container │
|
|
||||||
└────────┬────────────┘
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
┌─────────────────────┐
|
|
||||||
│ Coolify starts new │
|
|
||||||
│ container │
|
|
||||||
└────────┬────────────┘
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
┌─────────────────────┐
|
|
||||||
│ Health check │
|
|
||||||
│ verifies service │
|
|
||||||
└────────┬────────────┘
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
┌─────────────────────┐
|
|
||||||
│ ✅ Deployment │
|
|
||||||
│ Complete │
|
|
||||||
└─────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
## Image Specifications
|
|
||||||
|
|
||||||
### Server Image
|
|
||||||
- **Name**: nerd-monitor-server
|
|
||||||
- **Tag**: latest (or version-based)
|
|
||||||
- **Size**: ~40MB
|
|
||||||
- **Base**: alpine:latest
|
|
||||||
- **User**: nerdmonitor (uid: 1000)
|
|
||||||
- **Port**: 8080
|
|
||||||
- **Health Check**: Yes (30s interval)
|
|
||||||
|
|
||||||
### Agent Image
|
|
||||||
- **Name**: nerd-monitor-agent
|
|
||||||
- **Tag**: latest
|
|
||||||
- **Size**: ~15MB
|
|
||||||
- **Base**: alpine:latest
|
|
||||||
- **User**: nerdmonitor (uid: 1000)
|
|
||||||
- **Stateless**: Yes (no persistent storage)
|
|
||||||
|
|
||||||
## Environment Variables
|
|
||||||
|
|
||||||
### Server
|
|
||||||
```
|
|
||||||
ADDR=0.0.0.0 # Server bind address
|
|
||||||
PORT=8080 # Server port
|
|
||||||
USERNAME=admin # Admin username
|
|
||||||
PASSWORD=admin # Admin password (change!)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Agent
|
|
||||||
```
|
|
||||||
SERVER=localhost:8080 # Server address:port
|
|
||||||
INTERVAL=15s # Reporting interval
|
|
||||||
```
|
|
||||||
|
|
||||||
## Build Optimization
|
|
||||||
|
|
||||||
The Dockerfile uses several optimization techniques:
|
|
||||||
|
|
||||||
1. **Multi-stage Build**
|
|
||||||
- Builder stage: Includes compiler toolchain
|
|
||||||
- Runtime stage: Only includes runtime dependencies
|
|
||||||
- Result: Minimal final image size
|
|
||||||
|
|
||||||
2. **Alpine Linux**
|
|
||||||
- Lightweight base image (5-10MB)
|
|
||||||
- Includes essentials only
|
|
||||||
- Fast pull and startup
|
|
||||||
|
|
||||||
3. **Binary Optimization**
|
|
||||||
- `-w -s` flags strip debug symbols
|
|
||||||
- Reduces binary size by ~30%
|
|
||||||
- No runtime impact
|
|
||||||
|
|
||||||
4. **Non-root User**
|
|
||||||
- Improved security
|
|
||||||
- Prevents privilege escalation
|
|
||||||
- Best practice for containers
|
|
||||||
|
|
||||||
5. **Health Checks**
|
|
||||||
- Automatic service monitoring
|
|
||||||
- Coolify/Kubernetes aware
|
|
||||||
- Allows orchestration decisions
|
|
||||||
|
|
||||||
## Production Checklist
|
|
||||||
|
|
||||||
- [ ] Change USERNAME and PASSWORD in Coolify
|
|
||||||
- [ ] Enable HTTPS/SSL certificate
|
|
||||||
- [ ] Configure resource limits (CPU/Memory)
|
|
||||||
- [ ] Set up logging aggregation
|
|
||||||
- [ ] Configure backup strategy (if needed)
|
|
||||||
- [ ] Enable monitoring/alerts
|
|
||||||
- [ ] Test rollback procedure
|
|
||||||
- [ ] Document deployment process
|
|
||||||
- [ ] Set up redundancy if needed
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
### Build Fails
|
|
||||||
- Check Dockerfile syntax
|
|
||||||
- Verify build context includes all files
|
|
||||||
- Review build logs in Coolify
|
|
||||||
- Ensure .dockerignore isn't excluding source files
|
|
||||||
|
|
||||||
### Container Won't Start
|
|
||||||
- Check environment variables are set
|
|
||||||
- Verify port isn't already in use
|
|
||||||
- Check Docker logs: `docker logs container-name`
|
|
||||||
- Verify health check endpoint is accessible
|
|
||||||
|
|
||||||
### Deployment Shows Unhealthy
|
|
||||||
- Check network connectivity
|
|
||||||
- Verify PORT environment variable matches exposed port
|
|
||||||
- Review health check command
|
|
||||||
- Check application logs
|
|
||||||
|
|
||||||
### Image Size Too Large
|
|
||||||
- Remove unnecessary files from .dockerignore
|
|
||||||
- Use `docker image inspect` to analyze layers
|
|
||||||
- Consider multi-stage build optimization
|
|
||||||
|
|
||||||
## Performance Tips
|
|
||||||
|
|
||||||
1. **Caching**
|
|
||||||
- Copy go.mod/go.sum first (cached layer)
|
|
||||||
- Copy source code second
|
|
||||||
- Docker reuses layers if unchanged
|
|
||||||
|
|
||||||
2. **Build Speed**
|
|
||||||
- Use `docker buildx` for faster builds
|
|
||||||
- Enable BuildKit: `DOCKER_BUILDKIT=1`
|
|
||||||
- Parallelize stages if possible
|
|
||||||
|
|
||||||
3. **Runtime Performance**
|
|
||||||
- Alpine is lightweight but bare-bones
|
|
||||||
- Add tools only as needed
|
|
||||||
- Monitor resource usage
|
|
||||||
|
|
||||||
## Advanced Configuration
|
|
||||||
|
|
||||||
### Private Container Registry
|
|
||||||
If using private Docker registry:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# In Coolify, set registry credentials
|
|
||||||
docker login private-registry.example.com
|
|
||||||
|
|
||||||
# In docker-compose, use:
|
|
||||||
image: private-registry.example.com/nerd-monitor-server:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
### Multi-architecture Builds
|
|
||||||
Build for multiple architectures:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker buildx build \
|
|
||||||
--platform linux/amd64,linux/arm64 \
|
|
||||||
-t nerd-monitor-server:latest \
|
|
||||||
-f Dockerfile .
|
|
||||||
```
|
|
||||||
|
|
||||||
### Custom Base Images
|
|
||||||
Modify Dockerfile FROM directive:
|
|
||||||
|
|
||||||
```dockerfile
|
|
||||||
# Use different base image if needed
|
|
||||||
FROM golang:1.23-bookworm # Debian-based
|
|
||||||
FROM golang:1.23-bullseye # Another option
|
|
||||||
```
|
|
||||||
|
|
||||||
## Support & Documentation
|
|
||||||
|
|
||||||
- Review Dockerfile comments for details
|
|
||||||
- Check Coolify documentation for advanced features
|
|
||||||
- See README.md for general project info
|
|
||||||
- Review AGENTS.md for development guidelines
|
|
||||||
|
|
||||||
## Next Steps
|
|
||||||
|
|
||||||
1. Commit Docker files: `git add Dockerfile*`
|
|
||||||
2. Push to master: `git push origin master`
|
|
||||||
3. Coolify will automatically detect and build
|
|
||||||
4. Monitor build progress in Coolify UI
|
|
||||||
5. Access deployed application once ready
|
|
||||||
158
DOCKER_COMPOSE.md
Normal file
158
DOCKER_COMPOSE.md
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
# Docker Compose Quick Reference
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
### Full Stack (Server + Agent)
|
||||||
|
```bash
|
||||||
|
docker-compose up
|
||||||
|
```
|
||||||
|
Access dashboard: http://localhost:8080
|
||||||
|
Login: admin / admin
|
||||||
|
|
||||||
|
### Server Only
|
||||||
|
```bash
|
||||||
|
docker-compose up server
|
||||||
|
```
|
||||||
|
|
||||||
|
### Agent Only
|
||||||
|
```bash
|
||||||
|
SERVER=your-server:8080 docker-compose up agent
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Start services in background
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
# Stop all services
|
||||||
|
docker-compose down
|
||||||
|
|
||||||
|
# View logs
|
||||||
|
docker-compose logs -f
|
||||||
|
|
||||||
|
# View logs for specific service
|
||||||
|
docker-compose logs -f server
|
||||||
|
docker-compose logs -f agent
|
||||||
|
|
||||||
|
# Restart services
|
||||||
|
docker-compose restart
|
||||||
|
|
||||||
|
# Remove volumes/data
|
||||||
|
docker-compose down -v
|
||||||
|
|
||||||
|
# Rebuild images
|
||||||
|
docker-compose build --no-cache
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
### Change Server Credentials
|
||||||
|
Edit `docker-compose.yml`:
|
||||||
|
```yaml
|
||||||
|
environment:
|
||||||
|
USERNAME: "myuser"
|
||||||
|
PASSWORD: "mysecurepassword"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Change Agent Reporting Interval
|
||||||
|
```yaml
|
||||||
|
environment:
|
||||||
|
INTERVAL: "30s" # Report every 30 seconds instead of 15
|
||||||
|
```
|
||||||
|
|
||||||
|
### Set Custom Agent ID
|
||||||
|
```yaml
|
||||||
|
environment:
|
||||||
|
AGENT_ID: "my-machine"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run Multiple Agents
|
||||||
|
```bash
|
||||||
|
# Terminal 1: Start server
|
||||||
|
docker-compose up server
|
||||||
|
|
||||||
|
# Terminal 2: Run agent 1
|
||||||
|
docker-compose run --name agent1 -e AGENT_ID=machine1 agent
|
||||||
|
|
||||||
|
# Terminal 3: Run agent 2
|
||||||
|
docker-compose run --name agent2 -e AGENT_ID=machine2 agent
|
||||||
|
```
|
||||||
|
|
||||||
|
## Docker Commands
|
||||||
|
|
||||||
|
### View Running Containers
|
||||||
|
```bash
|
||||||
|
docker-compose ps
|
||||||
|
```
|
||||||
|
|
||||||
|
### Execute Commands in Container
|
||||||
|
```bash
|
||||||
|
# Connect to server
|
||||||
|
docker-compose exec server sh
|
||||||
|
|
||||||
|
# View server config
|
||||||
|
docker-compose exec server ps aux
|
||||||
|
```
|
||||||
|
|
||||||
|
### View Resource Usage
|
||||||
|
```bash
|
||||||
|
docker stats
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Agent can't connect to server
|
||||||
|
```bash
|
||||||
|
# Check if server is running and healthy
|
||||||
|
docker-compose ps
|
||||||
|
|
||||||
|
# Check server logs
|
||||||
|
docker-compose logs server
|
||||||
|
|
||||||
|
# Check if containers are on same network
|
||||||
|
docker network inspect nerd-monitor
|
||||||
|
```
|
||||||
|
|
||||||
|
### Clear Everything and Start Fresh
|
||||||
|
```bash
|
||||||
|
docker-compose down -v
|
||||||
|
docker-compose build --no-cache
|
||||||
|
docker-compose up
|
||||||
|
```
|
||||||
|
|
||||||
|
### Port Already in Use
|
||||||
|
If port 8080 is already in use, edit `docker-compose.yml`:
|
||||||
|
```yaml
|
||||||
|
ports:
|
||||||
|
- "8090:8080" # Maps host port 8090 to container port 8080
|
||||||
|
```
|
||||||
|
|
||||||
|
## Environment Variables Reference
|
||||||
|
|
||||||
|
### Server
|
||||||
|
| Variable | Default | Description |
|
||||||
|
|----------|---------|-------------|
|
||||||
|
| ADDR | 0.0.0.0 | Bind address |
|
||||||
|
| PORT | 8080 | Server port |
|
||||||
|
| USERNAME | admin | Admin username |
|
||||||
|
| PASSWORD | admin | Admin password |
|
||||||
|
|
||||||
|
### Agent
|
||||||
|
| Variable | Default | Description |
|
||||||
|
| SERVER | server:8080 | Server address |
|
||||||
|
| INTERVAL | 15s | Reporting interval |
|
||||||
|
| AGENT_ID | (auto) | Agent identifier |
|
||||||
|
|
||||||
|
## Production Tips
|
||||||
|
|
||||||
|
1. **Change credentials**: Update USERNAME and PASSWORD in docker-compose.yml
|
||||||
|
2. **Use external volumes**: Add volume mounts for data persistence
|
||||||
|
3. **Set resource limits**: Uncomment resource limits in docker-compose.yml
|
||||||
|
4. **Enable restart policies**: Already set to `unless-stopped`
|
||||||
|
5. **Use environment files**: Create `.env` file for sensitive data:
|
||||||
|
```bash
|
||||||
|
USERNAME=myuser
|
||||||
|
PASSWORD=mysecurepass
|
||||||
|
```
|
||||||
|
Then in docker-compose.yml: `env_file: .env`
|
||||||
60
Dockerfile
60
Dockerfile
@@ -1,60 +0,0 @@
|
|||||||
# Multi-stage Dockerfile for Nerd Monitor
|
|
||||||
# Optimized for Coolify CI/CD pipeline
|
|
||||||
# Build stage
|
|
||||||
FROM golang:1.23-alpine AS builder
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Install build dependencies
|
|
||||||
RUN apk add --no-cache git make
|
|
||||||
|
|
||||||
# Copy go mod files
|
|
||||||
COPY go.mod go.sum ./
|
|
||||||
|
|
||||||
# Download dependencies
|
|
||||||
RUN go mod download
|
|
||||||
|
|
||||||
# Copy source code
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Generate Templ templates
|
|
||||||
RUN go run github.com/a-h/templ/cmd/templ@latest generate
|
|
||||||
|
|
||||||
# Build the server
|
|
||||||
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-server ./cmd/server
|
|
||||||
|
|
||||||
# Runtime stage
|
|
||||||
FROM alpine:latest
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Install runtime dependencies
|
|
||||||
RUN apk add --no-cache ca-certificates tzdata
|
|
||||||
|
|
||||||
# Copy binary from builder
|
|
||||||
COPY --from=builder /app/bin/nerd-monitor-server /app/nerd-monitor-server
|
|
||||||
|
|
||||||
# Create non-root user for security
|
|
||||||
RUN addgroup -g 1000 nerdmonitor && adduser -D -u 1000 -G nerdmonitor nerdmonitor
|
|
||||||
|
|
||||||
# Change ownership
|
|
||||||
RUN chown -R nerdmonitor:nerdmonitor /app
|
|
||||||
|
|
||||||
# Switch to non-root user
|
|
||||||
USER nerdmonitor
|
|
||||||
|
|
||||||
# Expose port
|
|
||||||
EXPOSE 8080
|
|
||||||
|
|
||||||
# Health check
|
|
||||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
||||||
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/login || exit 1
|
|
||||||
|
|
||||||
# Default environment variables
|
|
||||||
ENV ADDR=0.0.0.0
|
|
||||||
ENV PORT=8080
|
|
||||||
ENV USERNAME=admin
|
|
||||||
ENV PASSWORD=admin
|
|
||||||
|
|
||||||
# Run the application
|
|
||||||
CMD ["/app/nerd-monitor-server", "-addr", "0.0.0.0", "-port", "8080", "-username", "admin", "-password", "admin"]
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Dockerfile for Nerd Monitor Agent
|
# Multi-stage build for nerd-monitor agent
|
||||||
# Multi-stage build optimized for minimal size
|
FROM golang:1.24.4-alpine AS builder
|
||||||
|
|
||||||
FROM golang:1.23-alpine AS builder
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -17,33 +15,31 @@ RUN go mod download
|
|||||||
# Copy source code
|
# Copy source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build the agent
|
# Build the agent binary (no templ needed for agent)
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o bin/nerd-monitor-agent ./cmd/agent
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o nerd-monitor-agent ./cmd/agent
|
||||||
|
|
||||||
# Runtime stage
|
# Runtime stage
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install runtime dependencies (minimal)
|
COPY --from=builder /app/nerd-monitor-agent .
|
||||||
RUN apk add --no-cache ca-certificates tzdata
|
|
||||||
|
|
||||||
# Copy binary from builder
|
# Create non-root user
|
||||||
COPY --from=builder /app/bin/nerd-monitor-agent /app/nerd-monitor-agent
|
RUN addgroup -D appgroup && adduser -D appuser -G appgroup
|
||||||
|
USER appuser
|
||||||
|
|
||||||
# Create non-root user for security
|
# Create entrypoint script to handle environment variables
|
||||||
RUN addgroup -g 1000 nerdmonitor && adduser -D -u 1000 -G nerdmonitor nerdmonitor
|
RUN echo '#!/bin/sh\n\
|
||||||
|
SERVER=${SERVER:-localhost:8080}\n\
|
||||||
# Change ownership
|
INTERVAL=${INTERVAL:-15s}\n\
|
||||||
RUN chown -R nerdmonitor:nerdmonitor /app
|
AGENT_ID=${AGENT_ID:-}\n\
|
||||||
|
if [ -z "$AGENT_ID" ]; then\n\
|
||||||
# Switch to non-root user
|
exec ./nerd-monitor-agent --server "$SERVER" --interval "$INTERVAL"\n\
|
||||||
USER nerdmonitor
|
else\n\
|
||||||
|
exec ./nerd-monitor-agent --server "$SERVER" --interval "$INTERVAL" --id "$AGENT_ID"\n\
|
||||||
# Default environment variables
|
fi\n\
|
||||||
ENV SERVER=localhost:8080
|
' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh
|
||||||
ENV INTERVAL=15s
|
|
||||||
|
|
||||||
# Run the agent
|
# Run the agent
|
||||||
ENTRYPOINT ["/app/nerd-monitor-agent"]
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
CMD ["--server", "${SERVER}", "--interval", "${INTERVAL}"]
|
|
||||||
|
|||||||
56
Dockerfile.server
Normal file
56
Dockerfile.server
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# Multi-stage build for nerd-monitor server
|
||||||
|
FROM golang:1.24.4-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install build dependencies
|
||||||
|
RUN apk add --no-cache git make
|
||||||
|
|
||||||
|
# Copy go mod files
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
|
# Download dependencies
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
# Copy source code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Generate templ templates
|
||||||
|
RUN go run github.com/a-h/templ/cmd/templ@latest generate
|
||||||
|
|
||||||
|
# Build the server binary
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o nerd-monitor-server ./cmd/server
|
||||||
|
|
||||||
|
# Runtime stage
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install ca-certificates for HTTPS
|
||||||
|
RUN apk add --no-cache ca-certificates
|
||||||
|
|
||||||
|
# Copy binary from builder
|
||||||
|
COPY --from=builder /app/nerd-monitor-server .
|
||||||
|
|
||||||
|
# Create non-root user
|
||||||
|
RUN addgroup -D appgroup && adduser -D appuser -G appgroup
|
||||||
|
USER appuser
|
||||||
|
|
||||||
|
# Expose port
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# Health check
|
||||||
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||||
|
CMD wget --quiet --tries=1 --spider http://localhost:8080/login || exit 1
|
||||||
|
|
||||||
|
# Create entrypoint script to handle environment variables
|
||||||
|
RUN echo '#!/bin/sh\n\
|
||||||
|
ADDR=${ADDR:-0.0.0.0}\n\
|
||||||
|
PORT=${PORT:-8080}\n\
|
||||||
|
USERNAME=${USERNAME:-admin}\n\
|
||||||
|
PASSWORD=${PASSWORD:-admin}\n\
|
||||||
|
exec ./nerd-monitor-server -addr "$ADDR" -port "$PORT" -username "$USERNAME" -password "$PASSWORD"\n\
|
||||||
|
' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh
|
||||||
|
|
||||||
|
# Run the server
|
||||||
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
151
GITEA_SETUP.md
Normal file
151
GITEA_SETUP.md
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
# Gitea Actions Setup - Server Configuration Checklist
|
||||||
|
|
||||||
|
This document outlines the changes needed on your Gitea server to make the CI/CD pipeline work.
|
||||||
|
|
||||||
|
## What You Need to Do
|
||||||
|
|
||||||
|
### 1. Add GITEA_TOKEN Secret to Repository
|
||||||
|
|
||||||
|
1. **Log into Gitea** with your user account
|
||||||
|
2. **Navigate to** your nerd-monitor repository
|
||||||
|
3. **Go to Settings → Secrets**
|
||||||
|
4. **Create a new secret**:
|
||||||
|
- Name: `GITEA_TOKEN`
|
||||||
|
- Value: [Your Gitea API token - see below for how to create]
|
||||||
|
5. **Save the secret**
|
||||||
|
|
||||||
|
### 2. Create an API Token (if you haven't already)
|
||||||
|
|
||||||
|
1. **Log into Gitea** with your user account
|
||||||
|
2. **Go to Settings → Applications**
|
||||||
|
3. **Click "Generate New Token"**
|
||||||
|
4. **Fill in the form**:
|
||||||
|
- Token Name: `release-automation`
|
||||||
|
- Scopes: Select at least `repo` (full repository access)
|
||||||
|
5. **Click "Generate"**
|
||||||
|
6. **Copy the token immediately** (you won't see it again)
|
||||||
|
7. **Use this token** for the secret in step 1
|
||||||
|
|
||||||
|
### 3. Verify Gitea Actions is Enabled (Server Admin)
|
||||||
|
|
||||||
|
These steps require SSH access to your Gitea server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# SSH into your Gitea server
|
||||||
|
ssh user@your-gitea-server
|
||||||
|
|
||||||
|
# Edit the Gitea configuration
|
||||||
|
sudo vi /etc/gitea/app.ini
|
||||||
|
|
||||||
|
# Verify or add this section:
|
||||||
|
[actions]
|
||||||
|
ENABLED = true
|
||||||
|
|
||||||
|
# Save and exit (Esc, :wq, Enter)
|
||||||
|
|
||||||
|
# Restart Gitea for changes to take effect
|
||||||
|
sudo systemctl restart gitea
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Verify Your Runner is Online (Server Admin)
|
||||||
|
|
||||||
|
1. **Log into Gitea** as admin
|
||||||
|
2. **Go to Administration → Actions → Runners**
|
||||||
|
3. **Verify** at least one runner is listed and shows as "Online" or "Idle"
|
||||||
|
4. If no runners:
|
||||||
|
- You need to set up a Gitea Actions runner on a machine with Docker and Go
|
||||||
|
- See "Setting Up a Runner" below
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
### Quick Runner Setup
|
||||||
|
|
||||||
|
1. **On your Gitea server or runner machine**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Download the Gitea Actions runner
|
||||||
|
wget https://github.com/gitea/act_runner/releases/download/v0.6.10/act_runner-0.6.10-linux-amd64
|
||||||
|
chmod +x act_runner-0.6.10-linux-amd64
|
||||||
|
|
||||||
|
# Register the runner with your Gitea instance
|
||||||
|
./act_runner-0.6.10-linux-amd64 register \
|
||||||
|
--instance https://git.nerdnest.dev \
|
||||||
|
--token <your-runner-token>
|
||||||
|
|
||||||
|
# Run the runner in the background
|
||||||
|
./act_runner-0.6.10-linux-amd64 daemon &
|
||||||
|
```
|
||||||
|
|
||||||
|
To get a runner token:
|
||||||
|
1. Log into Gitea as **admin**
|
||||||
|
2. Go to **Administration → Actions → Runners**
|
||||||
|
3. Click **Create new runner**
|
||||||
|
4. Follow the registration steps
|
||||||
|
|
||||||
|
## Testing the Setup
|
||||||
|
|
||||||
|
Once everything is configured:
|
||||||
|
|
||||||
|
1. **Push a test tag**:
|
||||||
|
```bash
|
||||||
|
git tag -a v0.0.1-test -m "Test release"
|
||||||
|
git push origin v0.0.1-test
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Monitor the build**:
|
||||||
|
- Go to Actions tab
|
||||||
|
- You should see the workflow running
|
||||||
|
- Check logs for any errors
|
||||||
|
|
||||||
|
3. **Verify the release**:
|
||||||
|
- Go to Releases tab
|
||||||
|
- You should see a new release with binaries and checksums
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### "Action not found" error
|
||||||
|
- Make sure Gitea Actions is enabled
|
||||||
|
- Restart Gitea if you just enabled it: `sudo systemctl restart gitea`
|
||||||
|
|
||||||
|
### No runners available
|
||||||
|
- Runner must be registered: Administration → Actions → Runners
|
||||||
|
- Runner machine must have Docker and Go installed
|
||||||
|
- Check if runner is online in the UI
|
||||||
|
|
||||||
|
### "GITEA_TOKEN" not found
|
||||||
|
- Make sure the secret is named exactly `GITEA_TOKEN` (case-sensitive)
|
||||||
|
- Go to Settings → Secrets and verify it's there
|
||||||
|
- If it's there, try re-running the workflow
|
||||||
|
|
||||||
|
### Build fails with permission denied
|
||||||
|
- Make sure the runner has permission to run Docker commands
|
||||||
|
- On the runner machine: `sudo usermod -aG docker $USER`
|
||||||
|
- 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
|
||||||
|
|
||||||
|
- Gitea Actions Docs: https://docs.gitea.io/en-us/actions/
|
||||||
|
- Act Runner Docs: https://gitea.com/gitea/act_runner
|
||||||
|
- For issues with the workflow itself, check the Actions tab logs
|
||||||
@@ -1,6 +1,45 @@
|
|||||||
# Nerd Monitor - Quick Start Guide
|
# Nerd Monitor - Quick Start Guide
|
||||||
|
|
||||||
## Building
|
## Docker Compose (Easiest)
|
||||||
|
|
||||||
|
The easiest way to get started is using Docker Compose:
|
||||||
|
|
||||||
|
### Run Full Stack (Server + Agent)
|
||||||
|
```bash
|
||||||
|
docker-compose up
|
||||||
|
```
|
||||||
|
|
||||||
|
Access the dashboard at: **http://localhost:8080**
|
||||||
|
|
||||||
|
### Run Server Only
|
||||||
|
```bash
|
||||||
|
docker-compose up server
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run Agent Only (with external server)
|
||||||
|
```bash
|
||||||
|
SERVER=your-server:8080 docker-compose up agent
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run Multiple Agents
|
||||||
|
```bash
|
||||||
|
# Start the server
|
||||||
|
docker-compose up -d server
|
||||||
|
|
||||||
|
# Run agents with custom IDs
|
||||||
|
docker-compose run --name agent1 -e AGENT_ID=machine1 agent
|
||||||
|
docker-compose run --name agent2 -e AGENT_ID=machine2 agent
|
||||||
|
```
|
||||||
|
|
||||||
|
### Docker Compose Configuration
|
||||||
|
Edit `docker-compose.yml` to customize:
|
||||||
|
- Server credentials: `USERNAME` and `PASSWORD`
|
||||||
|
- Agent reporting interval: `INTERVAL`
|
||||||
|
- Agent custom ID: `AGENT_ID`
|
||||||
|
|
||||||
|
## Native Binaries
|
||||||
|
|
||||||
|
### Building
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Build for current OS
|
# Build for current OS
|
||||||
@@ -111,6 +150,8 @@ Change these when starting the server:
|
|||||||
./bin/nerd-monitor-server -username myuser -password mysecurepass
|
./bin/nerd-monitor-server -username myuser -password mysecurepass
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or with Docker Compose, edit the `USERNAME` and `PASSWORD` environment variables in `docker-compose.yml`.
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
- **Server**: Web UI, API endpoint for agent stats, in-memory storage
|
- **Server**: Web UI, API endpoint for agent stats, in-memory storage
|
||||||
@@ -134,3 +175,8 @@ Change these when starting the server:
|
|||||||
- Verify server is running: `http://localhost:8080`
|
- Verify server is running: `http://localhost:8080`
|
||||||
- Check firewall rules allow the agent port
|
- Check firewall rules allow the agent port
|
||||||
- Ensure correct server address and port are specified
|
- Ensure correct server address and port are specified
|
||||||
|
|
||||||
|
### Docker Compose agents can't reach server
|
||||||
|
- Verify server is healthy: `docker ps` (server should show healthy status)
|
||||||
|
- Check both containers are on the same network: `docker network inspect nerd-monitor`
|
||||||
|
- Ensure `SERVER` environment variable is set to `server:8080` (the service name)
|
||||||
|
|||||||
300
RELEASE.md
Normal file
300
RELEASE.md
Normal file
@@ -0,0 +1,300 @@
|
|||||||
|
# Nerd Monitor - Release & Deployment Guide
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
## Automatic Release Pipeline
|
||||||
|
|
||||||
|
### How It Works
|
||||||
|
|
||||||
|
1. **Master Branch Push**: When you push to `master`, the workflow:
|
||||||
|
- Builds all platform binaries (Linux/macOS/Windows, amd64/arm64)
|
||||||
|
- Generates checksums (SHA256)
|
||||||
|
- Uploads artifacts for 30 days
|
||||||
|
- Builds Docker images (server & agent)
|
||||||
|
|
||||||
|
2. **Tag Creation**: When you create a tag (e.g., `v1.0.0`), the workflow:
|
||||||
|
- Does all of the above
|
||||||
|
- Creates a GitHub Release
|
||||||
|
- Uploads all binaries and Docker images to the release
|
||||||
|
|
||||||
|
### Supported Platforms
|
||||||
|
|
||||||
|
Binaries are built for:
|
||||||
|
- **Linux**: amd64, arm64
|
||||||
|
- **macOS**: amd64 (Intel), arm64 (Apple Silicon)
|
||||||
|
- **Windows**: amd64
|
||||||
|
|
||||||
|
Docker images are built for Linux containers.
|
||||||
|
|
||||||
|
## Workflow Configuration
|
||||||
|
|
||||||
|
The Gitea Actions workflow is defined in `.gitea/workflows/release.yml`
|
||||||
|
|
||||||
|
### Trigger Events
|
||||||
|
- Push to `master` branch
|
||||||
|
- Push of git tags (e.g., `v1.0.0`)
|
||||||
|
|
||||||
|
### Jobs
|
||||||
|
- `build`: Compiles all platform binaries and generates checksums
|
||||||
|
- `docker-build`: Builds Docker images for server and agent
|
||||||
|
|
||||||
|
### Creating a Release
|
||||||
|
|
||||||
|
#### Step 1: Create and Push a Tag
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Create an annotated tag
|
||||||
|
git tag -a v1.0.0 -m "Release version 1.0.0"
|
||||||
|
|
||||||
|
# Push the tag to Gitea
|
||||||
|
git push origin v1.0.0
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step 2: Monitor the Workflow
|
||||||
|
|
||||||
|
1. Go to your repository on Gitea
|
||||||
|
2. Click the **Actions** tab
|
||||||
|
3. You'll see the workflow running:
|
||||||
|
- `build` job: Compiles all binaries (5-10 minutes)
|
||||||
|
- `docker-build` job: Builds Docker images (5-10 minutes)
|
||||||
|
|
||||||
|
#### Step 3: Verify the Release
|
||||||
|
|
||||||
|
Once the workflow completes:
|
||||||
|
|
||||||
|
1. Go to the **Releases** tab
|
||||||
|
2. You'll see a new release with:
|
||||||
|
- All platform binaries (Linux, macOS, Windows)
|
||||||
|
- SHA256SUMS file with checksums
|
||||||
|
- Docker image files (.tar)
|
||||||
|
|
||||||
|
### What Gets Built and Released
|
||||||
|
|
||||||
|
When you push a tag, the workflow automatically:
|
||||||
|
|
||||||
|
**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)
|
||||||
|
|
||||||
|
**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
|
||||||
|
|
||||||
|
You can also build binaries locally:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build for current platform
|
||||||
|
make build
|
||||||
|
|
||||||
|
# Build for all platforms
|
||||||
|
make build-all
|
||||||
|
|
||||||
|
# Clean build artifacts
|
||||||
|
make clean
|
||||||
|
```
|
||||||
|
|
||||||
|
Binaries are created in the `bin/` directory.
|
||||||
|
|
||||||
|
## Docker Images
|
||||||
|
|
||||||
|
Two Docker images are built:
|
||||||
|
|
||||||
|
### Server Image
|
||||||
|
```bash
|
||||||
|
docker pull nerd-monitor-server:latest
|
||||||
|
docker run -p 8080:8080 nerd-monitor-server
|
||||||
|
```
|
||||||
|
|
||||||
|
### Agent Image
|
||||||
|
```bash
|
||||||
|
docker pull nerd-monitor-agent:latest
|
||||||
|
docker run nerd-monitor-agent --server your-server:8080
|
||||||
|
```
|
||||||
|
|
||||||
|
## Gitea Configuration
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
Before the CI/CD pipeline can create releases automatically, you need to:
|
||||||
|
|
||||||
|
1. **Ensure Gitea Actions is enabled** on your Gitea server
|
||||||
|
2. **Create a Gitea API Token** with release permissions
|
||||||
|
3. **Add the token as an Actions secret** in your repository
|
||||||
|
|
||||||
|
### Setup Instructions
|
||||||
|
|
||||||
|
#### 1. Enable Gitea Actions (Server Admin)
|
||||||
|
|
||||||
|
SSH into your Gitea server and verify Actions is enabled:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Edit the Gitea configuration
|
||||||
|
sudo vi /etc/gitea/app.ini
|
||||||
|
|
||||||
|
# Add or verify:
|
||||||
|
[actions]
|
||||||
|
ENABLED = true
|
||||||
|
```
|
||||||
|
|
||||||
|
Then restart Gitea:
|
||||||
|
```bash
|
||||||
|
sudo systemctl restart gitea
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. Create an API Token
|
||||||
|
|
||||||
|
1. Log in to Gitea with your user account
|
||||||
|
2. Go to **Settings** → **Applications**
|
||||||
|
3. Click **Generate New Token**
|
||||||
|
4. Fill in:
|
||||||
|
- **Token Name**: `release-automation` (or any descriptive name)
|
||||||
|
- **Scopes**: Select `repo` (full repository access)
|
||||||
|
5. Click **Generate Token**
|
||||||
|
6. **Copy the token** (you won't be able to see it again)
|
||||||
|
|
||||||
|
#### 3. Add Token as Repository Secret
|
||||||
|
|
||||||
|
1. Go to your repository on Gitea
|
||||||
|
2. Navigate to **Settings** → **Secrets**
|
||||||
|
3. Click **Add Secret**
|
||||||
|
4. Fill in:
|
||||||
|
- **Secret Name**: `GITEA_TOKEN`
|
||||||
|
- **Secret Value**: Paste the token you copied
|
||||||
|
5. Click **Save**
|
||||||
|
|
||||||
|
Now the workflow will be able to create releases automatically!
|
||||||
|
|
||||||
|
### Workflow Configuration
|
||||||
|
|
||||||
|
The Gitea Actions workflow is defined in `.gitea/workflows/release.yml`
|
||||||
|
|
||||||
|
### Trigger Events
|
||||||
|
- Push to `master` or `main` branch (builds only, no release)
|
||||||
|
- Push of git tags (e.g., `v1.0.0`) - triggers full release with uploads
|
||||||
|
|
||||||
|
Each release includes:
|
||||||
|
|
||||||
|
```
|
||||||
|
nerd-monitor-server-linux-amd64
|
||||||
|
nerd-monitor-server-linux-arm64
|
||||||
|
nerd-monitor-server-darwin-amd64
|
||||||
|
nerd-monitor-server-darwin-arm64
|
||||||
|
nerd-monitor-server-windows-amd64.exe
|
||||||
|
|
||||||
|
nerd-monitor-agent-linux-amd64
|
||||||
|
nerd-monitor-agent-linux-arm64
|
||||||
|
nerd-monitor-agent-darwin-amd64
|
||||||
|
nerd-monitor-agent-darwin-arm64
|
||||||
|
nerd-monitor-agent-windows-amd64.exe
|
||||||
|
|
||||||
|
SHA256SUMS (checksums for all binaries)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Coolify Integration
|
||||||
|
|
||||||
|
If you want to use Coolify for deployment:
|
||||||
|
|
||||||
|
1. **For Server Deployment**:
|
||||||
|
- Use `Dockerfile.server` as the build context
|
||||||
|
- Coolify will auto-build on `master` branch pushes
|
||||||
|
- Deploy the server container to Coolify
|
||||||
|
|
||||||
|
2. **For Agent Deployment**:
|
||||||
|
- Use `Dockerfile.agent` as the build context
|
||||||
|
- Deploy the agent container to machines that need monitoring
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Workflow Not Triggering
|
||||||
|
|
||||||
|
**Problem**: I pushed a tag but the workflow didn't start
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
1. Check that the tag is pushed: `git push origin v1.0.0`
|
||||||
|
2. Verify Gitea Actions is enabled: Settings → Actions → Status should show "Enabled"
|
||||||
|
3. Check Actions tab for any error messages
|
||||||
|
4. Ensure your runner is online: Settings → Runners
|
||||||
|
|
||||||
|
### Token Authentication Failed
|
||||||
|
|
||||||
|
**Problem**: `"message":"Unauthorized"` or token-related errors in the logs
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
1. Verify the `GITEA_TOKEN` secret is set correctly: Repository → Settings → Secrets
|
||||||
|
2. Ensure the token has `repo` scope permissions
|
||||||
|
3. Token should not be expired - regenerate if needed
|
||||||
|
4. Double-check there are no extra spaces in the token
|
||||||
|
|
||||||
|
### Build Fails with "Go not found"
|
||||||
|
|
||||||
|
**Problem**: Workflow fails when trying to build, says Go is not available
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
1. This is usually a temporary issue - runner environment might not have been fully initialized
|
||||||
|
2. Retry the workflow: Go to Actions tab → Click the failed workflow → Click "Re-run jobs"
|
||||||
|
3. Check if the runner has enough disk space: `df -h` on the runner machine
|
||||||
|
|
||||||
|
### Binaries Not Uploaded to Release
|
||||||
|
|
||||||
|
**Problem**: Workflow completes but binaries don't appear in the release
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
1. Check the workflow logs: Actions tab → Click the workflow → View logs
|
||||||
|
2. Look for "Uploading" messages and any error messages
|
||||||
|
3. Verify the release was created: Go to Releases tab
|
||||||
|
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
|
||||||
|
|
||||||
|
1. Go to your Gitea repository
|
||||||
|
2. Click the **Actions** tab
|
||||||
|
3. Click on the workflow run (should show the tag name)
|
||||||
|
4. Click on the job that failed (`build` or `docker-build`)
|
||||||
|
5. Scroll through the log to find error messages
|
||||||
|
6. Look for red `❌` marks indicating failures
|
||||||
|
|
||||||
|
### Manual Trigger for Testing
|
||||||
|
|
||||||
|
If you want to test the workflow without creating a full release:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Push to main/master branch (triggers build only, no release)
|
||||||
|
git push origin main
|
||||||
|
|
||||||
|
# Then push a tag when you're ready (triggers full release)
|
||||||
|
git tag -a v1.0.0 -m "Release"
|
||||||
|
git push origin v1.0.0
|
||||||
|
```
|
||||||
|
|
||||||
|
## Additional Resources
|
||||||
|
|
||||||
|
- [Gitea Actions Documentation](https://docs.gitea.io/en-us/actions/)
|
||||||
|
- [Project README](./README.md)
|
||||||
|
- [Quick Start Guide](./QUICKSTART.md)
|
||||||
|
- [Agent Guidelines](./AGENTS.md)
|
||||||
|
- [Docker Compose Guide](./DOCKER_COMPOSE.md)
|
||||||
@@ -1,57 +1,107 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# Nerd Monitor Docker Compose Configuration
|
||||||
|
# ============================================================================
|
||||||
|
#
|
||||||
|
# This file provides multiple ways to run Nerd Monitor:
|
||||||
|
#
|
||||||
|
# 1. Full Stack (Server + Agent):
|
||||||
|
# docker-compose up
|
||||||
|
#
|
||||||
|
# 2. Server Only:
|
||||||
|
# docker-compose up server
|
||||||
|
#
|
||||||
|
# 3. Agent Only (requires external server):
|
||||||
|
# docker-compose up agent
|
||||||
|
# (Set SERVER env var: SERVER=your-server:8080 docker-compose up agent)
|
||||||
|
#
|
||||||
|
# 4. Multiple Agents:
|
||||||
|
# docker-compose up -d server
|
||||||
|
# docker-compose run --name agent1 -e AGENT_ID=machine1 agent
|
||||||
|
# docker-compose run --name agent2 -e AGENT_ID=machine2 agent
|
||||||
|
#
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
# =========================================================================
|
||||||
# Nerd Monitor Server
|
# Nerd Monitor Server
|
||||||
|
# =========================================================================
|
||||||
|
# Web UI and API endpoint for collecting agent statistics
|
||||||
|
#
|
||||||
|
# Environment Variables:
|
||||||
|
# ADDR: Server bind address (default: 0.0.0.0)
|
||||||
|
# PORT: Server port (default: 8080)
|
||||||
|
# USERNAME: Admin username (default: admin)
|
||||||
|
# PASSWORD: Admin password (default: admin) - CHANGE IN PRODUCTION
|
||||||
|
#
|
||||||
server:
|
server:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile.server
|
||||||
container_name: nerd-monitor-server
|
container_name: nerd-monitor-server
|
||||||
|
image: nerd-monitor-server:latest
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
environment:
|
environment:
|
||||||
ADDR: 0.0.0.0
|
# Server configuration
|
||||||
PORT: 8080
|
ADDR: "0.0.0.0"
|
||||||
USERNAME: admin
|
PORT: "8080"
|
||||||
PASSWORD: admin
|
# IMPORTANT: Change these credentials in production!
|
||||||
volumes:
|
USERNAME: "admin"
|
||||||
- server-logs:/app/logs
|
PASSWORD: "admin"
|
||||||
restart: unless-stopped
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/login"]
|
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/login"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 3s
|
timeout: 3s
|
||||||
retries: 3
|
retries: 3
|
||||||
start_period: 5s
|
start_period: 5s
|
||||||
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- nerd-monitor-net
|
- nerd-monitor
|
||||||
labels:
|
# Resource limits (optional, uncomment to enable)
|
||||||
- "com.example.description=Nerd Monitor Server"
|
# deploy:
|
||||||
|
# resources:
|
||||||
|
# limits:
|
||||||
|
# cpus: '0.5'
|
||||||
|
# memory: 512M
|
||||||
|
|
||||||
# Example Agent 1 (Alpine-based, simulated)
|
# =========================================================================
|
||||||
# In production, agents run on monitored machines
|
# Nerd Monitor Agent
|
||||||
# This is for testing/demo purposes only
|
# =========================================================================
|
||||||
agent-demo:
|
# Lightweight monitoring agent that reports system stats to the server
|
||||||
|
#
|
||||||
|
# Environment Variables:
|
||||||
|
# SERVER: Server address (default: server:8080 when using docker-compose)
|
||||||
|
# INTERVAL: Reporting interval (default: 15s)
|
||||||
|
# AGENT_ID: Optional agent identifier (auto-generated from hostname if empty)
|
||||||
|
#
|
||||||
|
# Note: This agent depends on the server being healthy before starting
|
||||||
|
#
|
||||||
|
agent:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile.agent
|
dockerfile: Dockerfile.agent
|
||||||
container_name: nerd-monitor-agent-demo
|
image: nerd-monitor-agent:latest
|
||||||
environment:
|
environment:
|
||||||
SERVER: http://server:8080
|
# Agent configuration
|
||||||
INTERVAL: 15s
|
SERVER: "server:8080" # Connect to the server service
|
||||||
|
INTERVAL: "15s" # Report stats every 15 seconds
|
||||||
|
# AGENT_ID: "my-machine" # Optional: set a custom agent ID
|
||||||
depends_on:
|
depends_on:
|
||||||
server:
|
server:
|
||||||
condition: service_healthy
|
condition: service_healthy # Wait for server to be healthy
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- nerd-monitor-net
|
- nerd-monitor
|
||||||
labels:
|
# Resource limits (optional, uncomment to enable)
|
||||||
- "com.example.description=Nerd Monitor Agent (Demo)"
|
# deploy:
|
||||||
|
# resources:
|
||||||
volumes:
|
# limits:
|
||||||
server-logs:
|
# cpus: '0.25'
|
||||||
driver: local
|
# memory: 128M
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
nerd-monitor-net:
|
# Shared network for server and agent communication
|
||||||
|
nerd-monitor:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|||||||
57
scripts/upload-release.sh
Executable file
57
scripts/upload-release.sh
Executable file
@@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Script to upload release artifacts to Gitea
|
||||||
|
# Usage: ./scripts/upload-release.sh <tag> <gitea_token>
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
TAG="${1:?Tag is required (e.g., v1.0.0)}"
|
||||||
|
GITEA_TOKEN="${2:?Gitea API token is required}"
|
||||||
|
GITEA_URL="${GITEA_URL:-https://git.nerdnest.dev}"
|
||||||
|
REPO_OWNER="${REPO_OWNER:-ducky}"
|
||||||
|
REPO_NAME="${REPO_NAME:-nerd-monitor}"
|
||||||
|
BIN_DIR="./bin"
|
||||||
|
|
||||||
|
if [ ! -d "$BIN_DIR" ]; then
|
||||||
|
echo "Error: $BIN_DIR directory not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get or create release
|
||||||
|
echo "Getting release info for tag: $TAG"
|
||||||
|
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 for tag: $TAG"
|
||||||
|
RELEASE_JSON=$(curl -s -X POST \
|
||||||
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"Release $TAG\",\"draft\":false,\"prerelease\":false}" \
|
||||||
|
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases")
|
||||||
|
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id')
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Release ID: $RELEASE_ID"
|
||||||
|
|
||||||
|
# Upload all binaries
|
||||||
|
echo "Uploading release artifacts..."
|
||||||
|
for file in "$BIN_DIR"/*; 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
|
||||||
|
|
||||||
|
echo " ✓ $filename uploaded"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Release created/updated successfully!"
|
||||||
|
echo "View at: $GITEA_URL/$REPO_OWNER/$REPO_NAME/releases/tag/$TAG"
|
||||||
Reference in New Issue
Block a user