|
| 1 | +# GH Runner Docker |
| 2 | + |
| 3 | +Self-hosted GitHub Actions Runner in Docker Container |
| 4 | + |
| 5 | +## Compliance Statement |
| 6 | + |
| 7 | +⚠️ **Runner Usage Requirements** |
| 8 | +- Register only **one runner per container** |
| 9 | +- Use ephemeral mode for security-sensitive workflows |
| 10 | +- Keep runner updated to latest version |
| 11 | +- Limit network exposure of runner |
| 12 | +- Do not store secrets in runner configuration |
| 13 | + |
| 14 | +## Environment Variables |
| 15 | + |
| 16 | +`.env` configuration example: |
| 17 | +```dotenv |
| 18 | +# Runner configuration |
| 19 | +RUNNER_VERSION=2.328.0 |
| 20 | +RUNNER_URL=https://github.com/OWNER/REPO |
| 21 | +RUNNER_TOKEN=PASTE_REGISTRATION_TOKEN_HERE |
| 22 | +RUNNER_NAME=gh-runner |
| 23 | +RUNNER_LABELS=self-hosted,linux |
| 24 | +RUNNER_WORK=_work |
| 25 | +EPHEMERAL=false |
| 26 | +``` |
| 27 | + |
| 28 | +| Variable | Purpose | Default | |
| 29 | +|----------|---------|---------| |
| 30 | +| `RUNNER_VERSION` | GitHub Actions runner version | 2.328.0 | |
| 31 | +| `RUNNER_URL` | Repository URL for runner registration | - | |
| 32 | +| `RUNNER_TOKEN` | Registration token from GitHub | - | |
| 33 | +| `RUNNER_LABELS` | Comma-separated runner labels | self-hosted,linux | |
| 34 | +| `EPHEMERAL` | One-time use runner | false | |
| 35 | +| `RUNNER_NAME` | Custom runner name | gh-runner | |
| 36 | +| `RUNNER_WORK` | Working directory | _work | |
| 37 | + |
| 38 | +## Key Features |
| 39 | + |
| 40 | +**1. Multi-architecture Support:** |
| 41 | +```bash |
| 42 | +# Build for all supported platforms |
| 43 | +docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t ghcr.io/owner/gh-runner:latest . |
| 44 | +``` |
| 45 | + |
| 46 | +**2. Ephemeral Mode:** |
| 47 | +```bash |
| 48 | +# One-time runner that self-destructs after workflow |
| 49 | +EPHEMERAL=true |
| 50 | +``` |
| 51 | + |
| 52 | +**3. Automatic Configuration:** |
| 53 | +```text |
| 54 | +1. Container starts |
| 55 | +2. Registers with GitHub |
| 56 | +3. Creates health check file |
| 57 | +4. Starts listening for jobs |
| 58 | +5. Automatically unregisters on exit |
| 59 | +``` |
| 60 | + |
| 61 | +## Configuration Examples |
| 62 | + |
| 63 | +**Basic setup:** |
| 64 | +```bash |
| 65 | +RUNNER_URL=https://github.com/ponfertato/ponfertato |
| 66 | +RUNNER_TOKEN=abcdef1234567890 |
| 67 | +``` |
| 68 | + |
| 69 | +**Custom labels for specific workflows:** |
| 70 | +```bash |
| 71 | +RUNNER_LABELS=self-hosted,linux,arm64,cpu-intensive |
| 72 | +``` |
| 73 | + |
| 74 | +**Ephemeral runner for security:** |
| 75 | +```bash |
| 76 | +# Only runs one workflow then unregisters |
| 77 | +EPHEMERAL=true |
| 78 | +``` |
| 79 | + |
| 80 | +## Technical Architecture |
| 81 | + |
| 82 | +**Runner Lifecycle:** |
| 83 | +1. Container startup |
| 84 | +2. GitHub registration |
| 85 | +3. Health check initialization |
| 86 | +4. Job execution |
| 87 | +5. Automatic cleanup on exit |
| 88 | + |
| 89 | +**Multi-arch Support:** |
| 90 | +```text |
| 91 | +x86_64 → linux-x64 |
| 92 | +arm64 → linux-arm64 |
| 93 | +armv7 → linux-arm |
| 94 | +``` |
| 95 | + |
| 96 | +## Deployment |
| 97 | + |
| 98 | +**Build and push:** |
| 99 | +```bash |
| 100 | +docker compose -f gh-runner/docker-compose.yml build |
| 101 | +docker push ghcr.io/owner/gh-runner:2.328.0 |
| 102 | +``` |
| 103 | + |
| 104 | +**Run with Docker Compose:** |
| 105 | +```bash |
| 106 | +docker compose -f gh-runner/docker-compose.yml up -d |
| 107 | +``` |
| 108 | + |
| 109 | +## Scaling Configuration |
| 110 | + |
| 111 | +**Horizontal scaling:** |
| 112 | +```env |
| 113 | +# .env file |
| 114 | +REPLICAS=3 |
| 115 | +``` |
| 116 | + |
| 117 | +**Distributed workloads:** |
| 118 | +```yaml |
| 119 | +# docker-compose.yml |
| 120 | +deploy: |
| 121 | + replicas: ${REPLICAS} |
| 122 | +``` |
| 123 | +
|
| 124 | +## License |
| 125 | +
|
| 126 | +MIT License |
0 commit comments