Skip to content

Commit e87518a

Browse files
ggilestroclaude
andcommitted
feat(docker): Add automated Docker image publishing to GHCR
Add GitHub Actions workflow to build and push ethoscope-node and ethoscope-git-server images to ghcr.io on push to dev/main and version tags. Fix Dockerfile ARG scoping bug where ETHOSCOPE_BRANCH was declared before FROM and never propagated to RUN commands. Update docker-compose to reference GHCR images. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8604c8c commit e87518a

File tree

5 files changed

+141
-3
lines changed

5 files changed

+141
-3
lines changed

.github/CICD.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,39 @@ The Ethoscope project uses GitHub Actions for continuous integration and continu
121121
- ✅ Package validation
122122
- 🔄 PyPI publishing (ready to enable)
123123

124+
### 4. Docker Workflow (`.github/workflows/docker.yml`)
125+
126+
**Purpose**: Build and publish Docker images to GitHub Container Registry (GHCR)
127+
128+
**Triggers**:
129+
- Push to `dev` or `main` branches
130+
- Push of version tags (`v*.*.*`)
131+
- Manual workflow dispatch
132+
133+
**Jobs**:
134+
135+
#### `build-node`
136+
- Builds the ethoscope-node image from `Docker/node/node.dockerfile`
137+
- Passes the branch/tag name as `ETHOSCOPE_BRANCH` build argument
138+
- Pushes to `ghcr.io/gilestrolab/ethoscope-node`
139+
140+
#### `build-git-server`
141+
- Builds the git daemon image from `Docker/node/git-server/git-daemon.dockerfile`
142+
- Pushes to `ghcr.io/gilestrolab/ethoscope-git-server`
143+
144+
**Tagging Strategy**:
145+
| Trigger | Tags |
146+
|---------|------|
147+
| Push to `dev` | `dev` |
148+
| Push to `main` | `main`, `latest` |
149+
| Tag `v1.2.3` | `v1.2.3`, `1.2.3`, `1.2`, `latest` |
150+
151+
**Features**:
152+
- ✅ Automatic image publishing on push
153+
- ✅ Semantic version tagging
154+
- ✅ BuildKit layer caching via GitHub Actions cache
155+
- ✅ No extra secrets required (uses `GITHUB_TOKEN`)
156+
124157
## Setup Instructions
125158

126159
### 1. Enable Workflows
@@ -321,7 +354,7 @@ Consider adding:
321354
- [ ] Automated dependency updates (Dependabot)
322355
- [ ] Performance benchmarking
323356
- [ ] Documentation building and deployment
324-
- [ ] Docker image building and publishing
357+
- [x] Docker image building and publishing
325358
- [ ] Slack/Discord notifications for failures
326359
- [ ] Code coverage enforcement (fail below threshold)
327360

.github/workflows/docker.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches: [dev, main]
6+
tags: ["v*.*.*"]
7+
workflow_dispatch:
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
jobs:
17+
build-node:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: docker/login-action@v3
23+
with:
24+
registry: ${{ env.REGISTRY }}
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- uses: docker/metadata-action@v5
29+
id: meta
30+
with:
31+
images: ${{ env.REGISTRY }}/gilestrolab/ethoscope-node
32+
tags: |
33+
type=ref,event=branch
34+
type=semver,pattern=v{{version}}
35+
type=semver,pattern={{version}}
36+
type=semver,pattern={{major}}.{{minor}}
37+
type=raw,value=latest,enable={{is_default_branch}}
38+
39+
- uses: docker/setup-buildx-action@v3
40+
41+
- uses: docker/build-push-action@v6
42+
with:
43+
context: Docker/node
44+
file: Docker/node/node.dockerfile
45+
push: true
46+
tags: ${{ steps.meta.outputs.tags }}
47+
labels: ${{ steps.meta.outputs.labels }}
48+
build-args: ETHOSCOPE_BRANCH=${{ github.ref_name }}
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max
51+
52+
build-git-server:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- uses: docker/login-action@v3
58+
with:
59+
registry: ${{ env.REGISTRY }}
60+
username: ${{ github.actor }}
61+
password: ${{ secrets.GITHUB_TOKEN }}
62+
63+
- uses: docker/metadata-action@v5
64+
id: meta
65+
with:
66+
images: ${{ env.REGISTRY }}/gilestrolab/ethoscope-git-server
67+
tags: |
68+
type=ref,event=branch
69+
type=semver,pattern=v{{version}}
70+
type=semver,pattern={{version}}
71+
type=semver,pattern={{major}}.{{minor}}
72+
type=raw,value=latest,enable={{is_default_branch}}
73+
74+
- uses: docker/setup-buildx-action@v3
75+
76+
- uses: docker/build-push-action@v6
77+
with:
78+
context: Docker/node/git-server
79+
file: Docker/node/git-server/git-daemon.dockerfile
80+
push: true
81+
tags: ${{ steps.meta.outputs.tags }}
82+
labels: ${{ steps.meta.outputs.labels }}
83+
cache-from: type=gha
84+
cache-to: type=gha,mode=max

Docker/node/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
This directory contains Docker configuration for running the Ethoscope node system in containers.
44

5+
## Pre-built Images
6+
7+
Pre-built images are automatically published to GitHub Container Registry on every push to `dev` and `main`:
8+
9+
```bash
10+
# Pull the latest stable image
11+
docker pull ghcr.io/gilestrolab/ethoscope-node:latest
12+
13+
# Pull a specific branch
14+
docker pull ghcr.io/gilestrolab/ethoscope-node:dev
15+
16+
# Pull a specific release
17+
docker pull ghcr.io/gilestrolab/ethoscope-node:v1.0.0
18+
19+
# Git server image
20+
docker pull ghcr.io/gilestrolab/ethoscope-git-server:latest
21+
```
22+
23+
Available at: https://github.com/orgs/gilestrolab/packages
24+
525
## Quick Start
626

727
1. Copy the environment template:

Docker/node/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
dockerfile: node.dockerfile
1111
args:
1212
- ETHOSCOPE_BRANCH=dev
13-
image: ggilestro/ethoscope-node:latest
13+
image: ghcr.io/gilestrolab/ethoscope-node:latest
1414
restart: unless-stopped
1515
volumes:
1616
- ../../:/opt/ethoscope:ro # Uncomment if needed - will mount the host ethoscope folder, useful only for development
@@ -75,7 +75,7 @@ services:
7575
start_period: 15s
7676

7777
ethoscope-git-server:
78-
image: ggilestro/ethoscope-git-server:latest
78+
image: ghcr.io/gilestrolab/ethoscope-git-server:latest
7979
build:
8080
context: ./git-server
8181
dockerfile: git-daemon.dockerfile

Docker/node/node.dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
ARG ETHOSCOPE_BRANCH=dev
33
# Use the latest Arch Linux base image
44
FROM archlinux:latest
5+
ARG ETHOSCOPE_BRANCH=dev
56

67
# Update system and install base-devel and git for building AUR packages
78
RUN pacman -Sy \

0 commit comments

Comments
 (0)