Skip to content

Commit

Permalink
Merge pull request #298 from tvainika/ghcr-gh-action
Browse files Browse the repository at this point in the history
Build container image in GitHub Action

#298
  • Loading branch information
Augusto Hack authored Jan 7, 2022
2 parents 7f542c8 + e472110 commit 881c09b
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Create and publish a container image

on:
push:
# Publish main branch as `develop` image
branches:
- main
- master

# Publish tags as versioned release and `latest` image
tags:
- '*'

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

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build and push container image
run: |
# Image name may contain only lowercase letters
IMAGE_ID=$(echo ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# If not tag, then use `develop` as image tag
[ "$VERSION" == main -o "$VERSION" == master ] && VERSION=develop
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker build . --file container/Dockerfile \
--build-arg "CREATED=$(date --rfc-3339=seconds)" \
--build-arg "VERSION=$(git describe --always)" \
--build-arg "COMMIT=$(git rev-parse -q --verify HEAD^{commit})" \
--tag $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
if [[ "${{ github.ref }}" == "refs/tags/"* ]];
then
docker tag $IMAGE_ID:$VERSION $IMAGE_ID:latest
docker push $IMAGE_ID:latest
fi
10 changes: 9 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ Setup
Using Docker
------------

To get you up and running with the latest release of Karapace, a docker setup is available::
To get you up and running with the latest build of Karapace, a docker image is available::

# Fetch the latest build from main branch
docker pull ghcr.io/aiven/karapace:develop

# Fetch the latest release
docker pull ghcr.io/aiven/karapace:latest

An example setup including configuration and Kafka connection is available as docker-compose example::

docker-compose -f ./container/docker-compose.yml up -d

Expand Down
4 changes: 2 additions & 2 deletions container/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ services:
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"

karapace-registry:
image: aivenoy/karapace:latest
image: ghcr.io/aiven/karapace:develop
entrypoint:
- /bin/bash
- /opt/karapace/start.sh
Expand All @@ -78,7 +78,7 @@ services:
KARAPACE_COMPATIBILITY: FULL

karapace-rest:
image: aivenoy/karapace:latest
image: ghcr.io/aiven/karapace:develop
entrypoint:
- /bin/bash
- /opt/karapace/start.sh
Expand Down

0 comments on commit 881c09b

Please sign in to comment.