diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ad39f01..3be7453 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,21 +2,23 @@ name: Docker Builds on: push: - branches: [ main ] - paths: - - 'asap-common/installation/**' - - 'asap-planner/**' - - 'asap-tools/queriers/prometheus-client/**' - - '.github/workflows/docker.yml' + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' pull_request: - branches: [ main ] + branches: [main] paths: - 'asap-common/installation/**' - 'asap-planner/**' + - 'asap-sketch-ingest/**' + - 'asap-query-engine/**' - 'asap-tools/queriers/prometheus-client/**' - '.github/workflows/docker.yml' workflow_dispatch: +permissions: + packages: write + contents: read + jobs: build-images: runs-on: ubuntu-latest @@ -27,31 +29,86 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + # --- Base image (Python, fast) --- - name: Build base image - working-directory: asap-common/installation run: | docker build \ -t sketchdb-base:latest \ - -f Dockerfile \ - .. + -f asap-common/installation/Dockerfile \ + asap-common - - name: Test base image + - name: Push base image + if: startsWith(github.ref, 'refs/tags/') run: | - docker run --rm sketchdb-base:latest python --version - docker run --rm sketchdb-base:latest pip list + docker tag sketchdb-base:latest ghcr.io/projectasap/asap-base:${{ github.ref_name }} + docker tag sketchdb-base:latest ghcr.io/projectasap/asap-base:latest + docker push ghcr.io/projectasap/asap-base:${{ github.ref_name }} + docker push ghcr.io/projectasap/asap-base:latest - - name: Build Controller Docker image - working-directory: asap-planner + # --- Planner (Python, depends on base) --- + - name: Build planner image run: | docker build \ - -t sketchdb-controller:latest \ - -f Dockerfile \ - . + -t asap-planner:local \ + -f asap-planner/Dockerfile \ + asap-planner + + - name: Push planner image + if: startsWith(github.ref, 'refs/tags/') + run: | + docker tag asap-planner:local ghcr.io/projectasap/asap-planner:${{ github.ref_name }} + docker tag asap-planner:local ghcr.io/projectasap/asap-planner:latest + docker push ghcr.io/projectasap/asap-planner:${{ github.ref_name }} + docker push ghcr.io/projectasap/asap-planner:latest - - name: Build PrometheusClient Docker image - working-directory: asap-tools/queriers/prometheus-client + # --- Sketch Ingest (Python, depends on base) --- + - name: Build sketch-ingest image run: | docker build \ - -t sketchdb-prometheus-client:latest \ - -f Dockerfile \ - . + -t asap-sketch-ingest:local \ + -f asap-sketch-ingest/Dockerfile \ + asap-sketch-ingest + + - name: Push sketch-ingest image + if: startsWith(github.ref, 'refs/tags/') + run: | + docker tag asap-sketch-ingest:local ghcr.io/projectasap/asap-sketch-ingest:${{ github.ref_name }} + docker tag asap-sketch-ingest:local ghcr.io/projectasap/asap-sketch-ingest:latest + docker push ghcr.io/projectasap/asap-sketch-ingest:${{ github.ref_name }} + docker push ghcr.io/projectasap/asap-sketch-ingest:latest + + # --- Prometheus Client (Python, depends on base) --- + - name: Build prometheus-client image + run: | + docker build \ + -t asap-prometheus-client:local \ + -f asap-tools/queriers/prometheus-client/Dockerfile \ + asap-tools/queriers/prometheus-client + + - name: Push prometheus-client image + if: startsWith(github.ref, 'refs/tags/') + run: | + docker tag asap-prometheus-client:local ghcr.io/projectasap/asap-prometheus-client:${{ github.ref_name }} + docker tag asap-prometheus-client:local ghcr.io/projectasap/asap-prometheus-client:latest + docker push ghcr.io/projectasap/asap-prometheus-client:${{ github.ref_name }} + docker push ghcr.io/projectasap/asap-prometheus-client:latest + + # --- Query Engine (Rust, slow — uses GHCR layer cache) --- + - name: Build and push query-engine + uses: docker/build-push-action@v6 + with: + context: . + file: asap-query-engine/Dockerfile + push: ${{ startsWith(github.ref, 'refs/tags/') }} + tags: | + ghcr.io/projectasap/asap-query-engine:${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'pr-test' }} + ghcr.io/projectasap/asap-query-engine:latest + cache-from: type=registry,ref=ghcr.io/projectasap/asap-query-engine:buildcache + cache-to: type=registry,ref=ghcr.io/projectasap/asap-query-engine:buildcache,mode=max diff --git a/asap-sketch-ingest/Dockerfile b/asap-sketch-ingest/Dockerfile index 259e004..8432840 100644 --- a/asap-sketch-ingest/Dockerfile +++ b/asap-sketch-ingest/Dockerfile @@ -10,7 +10,6 @@ WORKDIR /app RUN pip3 install --no-cache-dir jinja2 requests loguru pyyaml # Copy application code -COPY classes/ ./classes/ COPY utils/ ./utils/ COPY templates/ ./templates/ COPY examples/ ./examples/ diff --git a/docs/03-how-to-guides/operations/publishing-docker-images.md b/docs/03-how-to-guides/operations/publishing-docker-images.md new file mode 100644 index 0000000..230cc43 --- /dev/null +++ b/docs/03-how-to-guides/operations/publishing-docker-images.md @@ -0,0 +1,47 @@ +# Publishing Docker Images to GHCR + +Docker images are published to `ghcr.io/projectasap/` by pushing a version tag. Nothing is published on regular commits or PRs. + +## How to publish a release + +```bash +git tag v0.2.0 +git push origin v0.2.0 +``` + +That's it. GitHub Actions will build and push all images tagged as both `v0.2.0` and `latest`. + +## Images published from this repo + +| Image | Source | +|---|---| +| `ghcr.io/projectasap/asap-base` | `asap-common/installation/` | +| `ghcr.io/projectasap/asap-planner` | `asap-planner/` | +| `ghcr.io/projectasap/asap-sketch-ingest` | `asap-sketch-ingest/` | +| `ghcr.io/projectasap/asap-query-engine` | `asap-query-engine/` | +| `ghcr.io/projectasap/asap-prometheus-client` | `asap-tools/queriers/prometheus-client/` | + +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. + +## Coordinating with the arroyo repo + +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. + +```bash +# In this repo +git tag v0.2.0 && git push origin v0.2.0 + +# In ProjectASAP/arroyo +git tag v0.2.0 && git push origin v0.2.0 +``` + +Then update the image tags in `asap-quickstart/` to `v0.2.0`. + +## If you need to delete a bad tag + +```bash +git tag -d v0.2.0 +git push origin :refs/tags/v0.2.0 +``` + +Then delete the package version manually in the GitHub UI under `github.com/orgs/ProjectASAP/packages` if images were already pushed.