Skip to content

Commit

Permalink
build: docker images (#39)
Browse files Browse the repository at this point in the history
Build docker images and push to ghcr.io

Fix release process and add `index` and `server` too, not only `client`

Prepare for 0.3.0 release
  • Loading branch information
luizirber authored Jan 29, 2025
1 parent af357cc commit c46e856
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 26 deletions.
157 changes: 157 additions & 0 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Based on
# - https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images
# - https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners

name: Create and publish Docker images

on:
push:
branches:
- 'main'
tags:
- 'v*'
## disabling for PRs, too many builds
# pull_request:
# branches:
# - 'main'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
target: [web, index, mongo]
platform:
- linux/amd64
- linux/arm64
include:
- platform: linux/amd64
os: ubuntu-latest
- platform: linux/arm64
os: ubuntu-24.04-arm

permissions:
contents: read
packages: write
id-token: write

steps:
- name: Delete huge unnecessary tools folder
run: |
rm -rf /opt/hostedtoolcache
cd /opt
find . -maxdepth 1 -mindepth 1 '!' -path ./containerd '!' -path ./actionarchivecache '!' -path ./runner '!' -path ./runner-cache -exec rm -rf '{}' ';'
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5

- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push by digest
id: build
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
target: ${{ matrix.target }}
outputs: type=image,"name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}",push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
name: digests-${{ matrix.target }}-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build

strategy:
matrix:
target: [web, index, mongo]

permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Download digests
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
path: ${{ runner.temp }}/digests
pattern: digests-${{ matrix.target }}-*
merge-multiple: true

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch,prefix=${{ matrix.target }}
type=ref,event=pr,prefix=${{ matrix.target }}-pr-
type=semver,prefix=${{ matrix.target }}-,pattern={{version}}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
# - name: Generate artifact attestation
# uses: actions/attest-build-provenance@v2
# with:
# subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# subject-digest: ${{ steps.build.outputs.digest }}
# push-to-registry: true
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default-members = ["crates/server"]
resolver = "2"

[workspace.package]
version = "0.2.0"
version = "0.3.0"
name = "branchwater"

[workspace.dependencies]
Expand Down
39 changes: 25 additions & 14 deletions crates/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,30 @@ branchwater-client --sig -o matches.csv \
## Available options

```
USAGE:
branchwater-client [OPTIONS] <SEQUENCES>
ARGS:
<SEQUENCES> Input file. Can be:
- sequences (FASTA/Q, compressed or not)
- an existing signature (use with --sig)
- a single dash ("-") for reading from stdin
OPTIONS:
-h, --help Print help information
-o, --output <OUTPUT> Save results to this file. Default: stdout
--sig Input file is already a signature
-V, --version Print version information
Usage: branchwater-client [OPTIONS] <SEQUENCES>
Arguments:
<SEQUENCES> Input file. Can be:
- sequences (FASTA/Q, compressed or not)
- an existing signature (use with --sig)
- a single dash ("-") for reading from stdin
Options:
-o, --output <OUTPUT>
Save results to this file. Default: stdout
-s, --server <SERVER>
Server to query. Default: https://api.branchwater.sourmash.bio [default: https://api.branchwater.sourmash.bio]
-m, --metadata-server <METADATA_SERVER>
Metadata server to query. Default: https://branchwater.sourmash.bio [default: https://branchwater.jgi.doe.gov]
--sig
Input file is already a signature
--full
Return full results (containment plus matching dataset ID metadata)
--retry <RETRY>
How many times to retry requests to the server (default: 3) [default: 3]
-h, --help
Print help
-V, --version
Print version
```

3 changes: 0 additions & 3 deletions crates/index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ edition = "2021"
license = "AGPL"
repository = "https://github.com/sourmash-bio/branchwater"

[package.metadata.dist]
dist = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
3 changes: 0 additions & 3 deletions crates/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ edition = "2021"
license = "AGPL"
repository = "https://github.com/sourmash-bio/branchwater"

[package.metadata.dist]
dist = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion dist-workspace.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ci = "github"
# The installers to generate for each app
installers = ["shell", "powershell"]
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "aarch64-pc-windows-msvc", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
# Path that installers should place binaries in
install-path = "CARGO_HOME"
# Whether to install an updater program
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
services:
index:
image: ghcr.io/sourmash-bio/branchwater:index-0.3.0
build:
context: .
dockerfile: Dockerfile
Expand All @@ -11,6 +12,7 @@ services:
- prod.index.env

mongodb:
image: ghcr.io/sourmash-bio/branchwater:mongo-0.3.0
build:
context: .
dockerfile: Dockerfile
Expand All @@ -22,6 +24,7 @@ services:
- ./metadata:/docker-entrypoint-initdb.d

app:
image: ghcr.io/sourmash-bio/branchwater:web-0.3.0
build:
context: .
dockerfile: Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "branchwater"
version = "0.1.0"
version = "0.3.0"
requires-python = ">=3.12.2,<3.13"

[tool.pixi.project]
Expand Down

0 comments on commit c46e856

Please sign in to comment.