Skip to content

Commit 0f1329f

Browse files
authored
ci: docker publish workflow for indexer-api + indexer-worker images (#52)
Builds + pushes both images to Docker Hub on every git tag (v*). Operators that want to self-host the Sentrix indexer get a clean path: docker pull sentriscloud/indexer-api:0.4.0 docker pull sentriscloud/indexer-worker:0.4.0 vs the current path of cloning the repo + pnpm install + docker compose build. :latest tag tracks the highest non-prerelease semver. Matrix builds api + worker in parallel using docker buildx with GHA cache (per-image scope so api builds don't invalidate worker cache). linux/amd64 only for now — arm64 emulation runs ~5x slower on x86 runners; opt in via a follow-up workflow when there's actual demand. Manual workflow_dispatch path for ad-hoc rebuilds (eg base-image security bump that doesn't ship a code change). Requires DOCKERHUB_USERNAME + DOCKERHUB_TOKEN repo secrets — add via Settings → Secrets and variables → Actions before tagging the first release. Image labels follow OCI spec — source / revision / version / license so registries that index labels (Docker Hub UI, GHCR, Artifact Hub) display the right metadata.
1 parent e453ba5 commit 0f1329f

1 file changed

Lines changed: 105 additions & 0 deletions

File tree

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: docker publish
2+
3+
# Builds + pushes the api and worker images to Docker Hub on every git
4+
# tag of the form v* (eg v0.4.0, v0.4.1-rc.0). Tags are derived from
5+
# the git tag so consumers can pin precisely:
6+
#
7+
# docker pull sentriscloud/indexer-api:0.4.0
8+
# docker pull sentriscloud/indexer-worker:0.4.0
9+
#
10+
# `latest` is also pushed when the tag is a non-prerelease semver (no
11+
# hyphen suffix), so `:latest` always points at a stable release.
12+
#
13+
# Manual workflow_dispatch is allowed for ad-hoc rebuilds (eg after a
14+
# base-image security bump that doesn't ship a code change). The
15+
# operator picks which tag to rebuild via the input.
16+
17+
on:
18+
push:
19+
tags:
20+
- 'v*'
21+
workflow_dispatch:
22+
inputs:
23+
tag:
24+
description: 'git tag to rebuild (eg v0.4.0)'
25+
required: true
26+
type: string
27+
28+
permissions:
29+
contents: read
30+
31+
jobs:
32+
build:
33+
name: build + push (${{ matrix.image }})
34+
runs-on: ubuntu-22.04
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
include:
39+
- image: indexer-api
40+
dockerfile: apps/api/Dockerfile
41+
- image: indexer-worker
42+
dockerfile: apps/indexer/Dockerfile
43+
steps:
44+
- uses: actions/checkout@v5
45+
with:
46+
ref: ${{ inputs.tag || github.ref }}
47+
48+
- uses: docker/setup-qemu-action@v3
49+
- uses: docker/setup-buildx-action@v3
50+
51+
- name: Log in to Docker Hub
52+
uses: docker/login-action@v3
53+
with:
54+
username: ${{ secrets.DOCKERHUB_USERNAME }}
55+
password: ${{ secrets.DOCKERHUB_TOKEN }}
56+
57+
- name: Resolve version tag
58+
id: ver
59+
run: |
60+
REF="${{ inputs.tag || github.ref_name }}"
61+
# Strip leading 'v' so the docker tag matches semver convention.
62+
VERSION="${REF#v}"
63+
echo "version=$VERSION" >> $GITHUB_OUTPUT
64+
# Push :latest only on non-prerelease (no '-' suffix).
65+
if [[ "$VERSION" != *-* ]]; then
66+
echo "latest=true" >> $GITHUB_OUTPUT
67+
else
68+
echo "latest=false" >> $GITHUB_OUTPUT
69+
fi
70+
71+
- name: Compose docker tags
72+
id: tags
73+
run: |
74+
TAGS="sentriscloud/${{ matrix.image }}:${{ steps.ver.outputs.version }}"
75+
if [ "${{ steps.ver.outputs.latest }}" = "true" ]; then
76+
TAGS="$TAGS,sentriscloud/${{ matrix.image }}:latest"
77+
fi
78+
# Multi-line for buildx --tag flag.
79+
{
80+
echo 'tags<<EOF'
81+
echo "$TAGS" | tr ',' '\n'
82+
echo 'EOF'
83+
} >> $GITHUB_OUTPUT
84+
85+
- name: Build + push
86+
uses: docker/build-push-action@v6
87+
with:
88+
context: .
89+
file: ${{ matrix.dockerfile }}
90+
push: true
91+
# linux/amd64 only for now — arm64 build infrastructure
92+
# (qemu emulation on x86 runners) takes ~5x longer; opt in
93+
# via a follow-up workflow when arm64 demand surfaces.
94+
platforms: linux/amd64
95+
tags: ${{ steps.tags.outputs.tags }}
96+
labels: |
97+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
98+
org.opencontainers.image.revision=${{ github.sha }}
99+
org.opencontainers.image.version=${{ steps.ver.outputs.version }}
100+
org.opencontainers.image.licenses=MIT
101+
cache-from: type=gha,scope=${{ matrix.image }}
102+
cache-to: type=gha,mode=max,scope=${{ matrix.image }}
103+
104+
- name: Image digest
105+
run: echo "${{ matrix.image }}:${{ steps.ver.outputs.version }} → built + pushed"

0 commit comments

Comments
 (0)