Skip to content

Commit 5946aa9

Browse files
Modified CI to build packages based on tags (#172)
* Modified CI to build packages based on tagsl * Fixed CI * Removed extra line from Dockerfile
1 parent 4fad4d3 commit 5946aa9

3 files changed

Lines changed: 127 additions & 24 deletions

File tree

.github/workflows/docker.yml

Lines changed: 80 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@ name: Docker Builds
22

33
on:
44
push:
5-
branches: [ main ]
6-
paths:
7-
- 'asap-common/installation/**'
8-
- 'asap-planner/**'
9-
- 'asap-tools/queriers/prometheus-client/**'
10-
- '.github/workflows/docker.yml'
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+*'
117
pull_request:
12-
branches: [ main ]
8+
branches: [main]
139
paths:
1410
- 'asap-common/installation/**'
1511
- 'asap-planner/**'
12+
- 'asap-sketch-ingest/**'
13+
- 'asap-query-engine/**'
1614
- 'asap-tools/queriers/prometheus-client/**'
1715
- '.github/workflows/docker.yml'
1816
workflow_dispatch:
1917

18+
permissions:
19+
packages: write
20+
contents: read
21+
2022
jobs:
2123
build-images:
2224
runs-on: ubuntu-latest
@@ -27,31 +29,86 @@ jobs:
2729
- name: Set up Docker Buildx
2830
uses: docker/setup-buildx-action@v3
2931

32+
- name: Login to GHCR
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.repository_owner }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
# --- Base image (Python, fast) ---
3040
- name: Build base image
31-
working-directory: asap-common/installation
3241
run: |
3342
docker build \
3443
-t sketchdb-base:latest \
35-
-f Dockerfile \
36-
..
44+
-f asap-common/installation/Dockerfile \
45+
asap-common
3746
38-
- name: Test base image
47+
- name: Push base image
48+
if: startsWith(github.ref, 'refs/tags/')
3949
run: |
40-
docker run --rm sketchdb-base:latest python --version
41-
docker run --rm sketchdb-base:latest pip list
50+
docker tag sketchdb-base:latest ghcr.io/projectasap/asap-base:${{ github.ref_name }}
51+
docker tag sketchdb-base:latest ghcr.io/projectasap/asap-base:latest
52+
docker push ghcr.io/projectasap/asap-base:${{ github.ref_name }}
53+
docker push ghcr.io/projectasap/asap-base:latest
4254
43-
- name: Build Controller Docker image
44-
working-directory: asap-planner
55+
# --- Planner (Python, depends on base) ---
56+
- name: Build planner image
4557
run: |
4658
docker build \
47-
-t sketchdb-controller:latest \
48-
-f Dockerfile \
49-
.
59+
-t asap-planner:local \
60+
-f asap-planner/Dockerfile \
61+
asap-planner
62+
63+
- name: Push planner image
64+
if: startsWith(github.ref, 'refs/tags/')
65+
run: |
66+
docker tag asap-planner:local ghcr.io/projectasap/asap-planner:${{ github.ref_name }}
67+
docker tag asap-planner:local ghcr.io/projectasap/asap-planner:latest
68+
docker push ghcr.io/projectasap/asap-planner:${{ github.ref_name }}
69+
docker push ghcr.io/projectasap/asap-planner:latest
5070
51-
- name: Build PrometheusClient Docker image
52-
working-directory: asap-tools/queriers/prometheus-client
71+
# --- Sketch Ingest (Python, depends on base) ---
72+
- name: Build sketch-ingest image
5373
run: |
5474
docker build \
55-
-t sketchdb-prometheus-client:latest \
56-
-f Dockerfile \
57-
.
75+
-t asap-sketch-ingest:local \
76+
-f asap-sketch-ingest/Dockerfile \
77+
asap-sketch-ingest
78+
79+
- name: Push sketch-ingest image
80+
if: startsWith(github.ref, 'refs/tags/')
81+
run: |
82+
docker tag asap-sketch-ingest:local ghcr.io/projectasap/asap-sketch-ingest:${{ github.ref_name }}
83+
docker tag asap-sketch-ingest:local ghcr.io/projectasap/asap-sketch-ingest:latest
84+
docker push ghcr.io/projectasap/asap-sketch-ingest:${{ github.ref_name }}
85+
docker push ghcr.io/projectasap/asap-sketch-ingest:latest
86+
87+
# --- Prometheus Client (Python, depends on base) ---
88+
- name: Build prometheus-client image
89+
run: |
90+
docker build \
91+
-t asap-prometheus-client:local \
92+
-f asap-tools/queriers/prometheus-client/Dockerfile \
93+
asap-tools/queriers/prometheus-client
94+
95+
- name: Push prometheus-client image
96+
if: startsWith(github.ref, 'refs/tags/')
97+
run: |
98+
docker tag asap-prometheus-client:local ghcr.io/projectasap/asap-prometheus-client:${{ github.ref_name }}
99+
docker tag asap-prometheus-client:local ghcr.io/projectasap/asap-prometheus-client:latest
100+
docker push ghcr.io/projectasap/asap-prometheus-client:${{ github.ref_name }}
101+
docker push ghcr.io/projectasap/asap-prometheus-client:latest
102+
103+
# --- Query Engine (Rust, slow — uses GHCR layer cache) ---
104+
- name: Build and push query-engine
105+
uses: docker/build-push-action@v6
106+
with:
107+
context: .
108+
file: asap-query-engine/Dockerfile
109+
push: ${{ startsWith(github.ref, 'refs/tags/') }}
110+
tags: |
111+
ghcr.io/projectasap/asap-query-engine:${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'pr-test' }}
112+
ghcr.io/projectasap/asap-query-engine:latest
113+
cache-from: type=registry,ref=ghcr.io/projectasap/asap-query-engine:buildcache
114+
cache-to: type=registry,ref=ghcr.io/projectasap/asap-query-engine:buildcache,mode=max

asap-sketch-ingest/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ WORKDIR /app
1010
RUN pip3 install --no-cache-dir jinja2 requests loguru pyyaml
1111

1212
# Copy application code
13-
COPY classes/ ./classes/
1413
COPY utils/ ./utils/
1514
COPY templates/ ./templates/
1615
COPY examples/ ./examples/
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Publishing Docker Images to GHCR
2+
3+
Docker images are published to `ghcr.io/projectasap/` by pushing a version tag. Nothing is published on regular commits or PRs.
4+
5+
## How to publish a release
6+
7+
```bash
8+
git tag v0.2.0
9+
git push origin v0.2.0
10+
```
11+
12+
That's it. GitHub Actions will build and push all images tagged as both `v0.2.0` and `latest`.
13+
14+
## Images published from this repo
15+
16+
| Image | Source |
17+
|---|---|
18+
| `ghcr.io/projectasap/asap-base` | `asap-common/installation/` |
19+
| `ghcr.io/projectasap/asap-planner` | `asap-planner/` |
20+
| `ghcr.io/projectasap/asap-sketch-ingest` | `asap-sketch-ingest/` |
21+
| `ghcr.io/projectasap/asap-query-engine` | `asap-query-engine/` |
22+
| `ghcr.io/projectasap/asap-prometheus-client` | `asap-tools/queriers/prometheus-client/` |
23+
24+
The arroyo image (`ghcr.io/projectasap/asap-arroyo`) is published separately from the [ProjectASAP/arroyo](https://github.com/ProjectASAP/arroyo) repo using the same process.
25+
26+
## Coordinating with the arroyo repo
27+
28+
The quickstart docker-compose pins specific image versions. When cutting a release, tag both repos with the same version and update the quickstart compose file to reference the new tags.
29+
30+
```bash
31+
# In this repo
32+
git tag v0.2.0 && git push origin v0.2.0
33+
34+
# In ProjectASAP/arroyo
35+
git tag v0.2.0 && git push origin v0.2.0
36+
```
37+
38+
Then update the image tags in `asap-quickstart/` to `v0.2.0`.
39+
40+
## If you need to delete a bad tag
41+
42+
```bash
43+
git tag -d v0.2.0
44+
git push origin :refs/tags/v0.2.0
45+
```
46+
47+
Then delete the package version manually in the GitHub UI under `github.com/orgs/ProjectASAP/packages` if images were already pushed.

0 commit comments

Comments
 (0)