|
| 1 | +# CI/CD Setup Guide |
| 2 | + |
| 3 | +This project uses GitHub Actions to automatically build and publish Docker images to Docker Hub when you create version tags. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. A Docker Hub account |
| 8 | +2. A Docker Hub repository (e.g., `awkto/kea-gui-reservations`) |
| 9 | + |
| 10 | +## Setup Instructions |
| 11 | + |
| 12 | +### Step 1: Configure Docker Hub Repository Name |
| 13 | + |
| 14 | +Edit `.github/workflows/docker-publish.yml` and update the `DOCKER_IMAGE_NAME`: |
| 15 | + |
| 16 | +```yaml |
| 17 | +env: |
| 18 | + DOCKER_IMAGE_NAME: YOUR_DOCKERHUB_USERNAME/kea-gui-reservations |
| 19 | +``` |
| 20 | +
|
| 21 | +### Step 2: Add Docker Hub Secrets to GitHub |
| 22 | +
|
| 23 | +1. Go to your GitHub repository |
| 24 | +2. Click **Settings** → **Secrets and variables** → **Actions** |
| 25 | +3. Click **New repository secret** |
| 26 | +4. Add two secrets: |
| 27 | +
|
| 28 | + **Secret 1: DOCKER_USERNAME** |
| 29 | + - Name: `DOCKER_USERNAME` |
| 30 | + - Value: Your Docker Hub username |
| 31 | + |
| 32 | + **Secret 2: DOCKER_PASSWORD** |
| 33 | + - Name: `DOCKER_PASSWORD` |
| 34 | + - Value: Your Docker Hub access token (NOT your password!) |
| 35 | + |
| 36 | +#### How to Create a Docker Hub Access Token: |
| 37 | + |
| 38 | +1. Log in to [Docker Hub](https://hub.docker.com/) |
| 39 | +2. Click your username → **Account Settings** |
| 40 | +3. Go to **Security** → **Access Tokens** |
| 41 | +4. Click **New Access Token** |
| 42 | +5. Give it a name (e.g., "GitHub Actions") |
| 43 | +6. Set permissions to **Read, Write, Delete** |
| 44 | +7. Click **Generate** |
| 45 | +8. **Copy the token** (you won't be able to see it again!) |
| 46 | +9. Use this token as the `DOCKER_PASSWORD` secret value |
| 47 | + |
| 48 | +### Step 3: Create a Version Tag |
| 49 | + |
| 50 | +When you're ready to publish a new version: |
| 51 | + |
| 52 | +```bash |
| 53 | +# Commit your changes |
| 54 | +git add . |
| 55 | +git commit -m "Release version 1.0.0" |
| 56 | +
|
| 57 | +# Create and push a version tag |
| 58 | +git tag v1.0.0 |
| 59 | +git push origin v1.0.0 |
| 60 | +``` |
| 61 | + |
| 62 | +Or create a tag for a specific commit: |
| 63 | + |
| 64 | +```bash |
| 65 | +git tag v1.0.0 abc1234 |
| 66 | +git push origin v1.0.0 |
| 67 | +``` |
| 68 | + |
| 69 | +### Step 4: Watch the Build |
| 70 | + |
| 71 | +1. Go to your GitHub repository |
| 72 | +2. Click the **Actions** tab |
| 73 | +3. You'll see the workflow running |
| 74 | +4. Wait for it to complete (usually 2-5 minutes) |
| 75 | + |
| 76 | +### Step 5: Verify the Image |
| 77 | + |
| 78 | +Once the workflow completes: |
| 79 | + |
| 80 | +```bash |
| 81 | +# Pull the image |
| 82 | +docker pull awkto/kea-gui-reservations:1.0.0 |
| 83 | +
|
| 84 | +# Or pull the latest |
| 85 | +docker pull awkto/kea-gui-reservations:latest |
| 86 | +``` |
| 87 | + |
| 88 | +## What the Workflow Does |
| 89 | + |
| 90 | +When you push a tag like `v1.0.0`, the workflow: |
| 91 | + |
| 92 | +1. ✅ Checks out your code |
| 93 | +2. ✅ Extracts the version number (removes the 'v' prefix) |
| 94 | +3. ✅ Builds a Docker image for **multiple platforms** (amd64 and arm64) |
| 95 | +4. ✅ Pushes the image with **two tags**: |
| 96 | + - `awkto/kea-gui-reservations:1.0.0` (version-specific) |
| 97 | + - `awkto/kea-gui-reservations:latest` (always points to newest) |
| 98 | +5. ✅ Creates a **GitHub Release** with the tag |
| 99 | +6. ✅ Adds release notes with Docker pull/run commands |
| 100 | + |
| 101 | +## Version Tag Format |
| 102 | + |
| 103 | +Use semantic versioning tags: |
| 104 | +- `v1.0.0` - Major release |
| 105 | +- `v1.1.0` - Minor release (new features) |
| 106 | +- `v1.1.1` - Patch release (bug fixes) |
| 107 | +- `v2.0.0-beta.1` - Pre-release |
| 108 | + |
| 109 | +The `v` prefix is required! |
| 110 | + |
| 111 | +## Multi-Platform Support |
| 112 | + |
| 113 | +The workflow builds for: |
| 114 | +- `linux/amd64` (Intel/AMD x86_64) |
| 115 | +- `linux/arm64` (ARM 64-bit, e.g., Raspberry Pi 4, Apple Silicon) |
| 116 | + |
| 117 | +This means the same image works on most systems! |
| 118 | + |
| 119 | +## Caching |
| 120 | + |
| 121 | +The workflow uses GitHub Actions cache to speed up builds: |
| 122 | +- First build: ~3-5 minutes |
| 123 | +- Subsequent builds: ~1-2 minutes |
| 124 | + |
| 125 | +## Troubleshooting |
| 126 | + |
| 127 | +### Error: "denied: requested access to the resource is denied" |
| 128 | + |
| 129 | +- Check that `DOCKER_USERNAME` and `DOCKER_PASSWORD` secrets are set correctly |
| 130 | +- Verify the Docker Hub repository exists |
| 131 | +- Make sure the access token has **Write** permissions |
| 132 | + |
| 133 | +### Error: "repository name must be lowercase" |
| 134 | + |
| 135 | +- Update `DOCKER_IMAGE_NAME` to use lowercase only |
| 136 | + |
| 137 | +### Workflow doesn't trigger |
| 138 | + |
| 139 | +- Make sure you pushed the tag: `git push origin v1.0.0` |
| 140 | +- Tag must start with `v` followed by a version number |
| 141 | + |
| 142 | +### Want to build on every push? |
| 143 | + |
| 144 | +Change the trigger in `.github/workflows/docker-publish.yml`: |
| 145 | + |
| 146 | +```yaml |
| 147 | +on: |
| 148 | + push: |
| 149 | + branches: |
| 150 | + - main |
| 151 | + tags: |
| 152 | + - 'v*.*.*' |
| 153 | +``` |
| 154 | + |
| 155 | +## Manual Trigger (Optional) |
| 156 | + |
| 157 | +To allow manual workflow runs, add: |
| 158 | + |
| 159 | +```yaml |
| 160 | +on: |
| 161 | + push: |
| 162 | + tags: |
| 163 | + - 'v*.*.*' |
| 164 | + workflow_dispatch: # Adds "Run workflow" button in GitHub |
| 165 | +``` |
| 166 | + |
| 167 | +## Example Release Process |
| 168 | + |
| 169 | +```bash |
| 170 | +# 1. Make your changes |
| 171 | +git add . |
| 172 | +git commit -m "Add new feature" |
| 173 | +
|
| 174 | +# 2. Push to main |
| 175 | +git push origin main |
| 176 | +
|
| 177 | +# 3. When ready to release, create a tag |
| 178 | +git tag v1.0.0 |
| 179 | +git push origin v1.0.0 |
| 180 | +
|
| 181 | +# 4. Go to GitHub Actions and watch the build |
| 182 | +
|
| 183 | +# 5. Once complete, users can pull: |
| 184 | +docker pull awkto/kea-gui-reservations:latest |
| 185 | +``` |
| 186 | + |
| 187 | +## Using the Published Image |
| 188 | + |
| 189 | +Once published, users can use your image: |
| 190 | + |
| 191 | +```bash |
| 192 | +# Pull the image |
| 193 | +docker pull awkto/kea-gui-reservations:latest |
| 194 | +
|
| 195 | +# Run with custom config |
| 196 | +docker run -d \ |
| 197 | + --name kea-gui \ |
| 198 | + -p 5000:5000 \ |
| 199 | + -v $(pwd)/config.yaml:/app/config/config.yaml:ro \ |
| 200 | + awkto/kea-gui-reservations:latest |
| 201 | +
|
| 202 | +# Or use docker-compose |
| 203 | +docker-compose up -d |
| 204 | +``` |
| 205 | + |
| 206 | +## Benefits |
| 207 | + |
| 208 | +✅ Automated builds - no manual Docker commands needed |
| 209 | +✅ Multi-platform support - works on x86_64 and ARM |
| 210 | +✅ Version tracking - every release is tagged |
| 211 | +✅ GitHub Releases - automatic changelog |
| 212 | +✅ Fast builds - uses layer caching |
| 213 | +✅ Latest tag - always points to newest version |
| 214 | + |
| 215 | +--- |
| 216 | + |
| 217 | +Need help? Check the [GitHub Actions documentation](https://docs.github.com/en/actions) or open an issue! |
0 commit comments