diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..a03961a --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,41 @@ +name: Build & publish event-streams-samples images +on: + push: + branches: ['master'] + paths: + - 'kafka-java-console-sample/**' + +env: + REGISTRY: ghcr.io + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - directory: kafka-java-console-sample + image: kafka-java-console-sample:latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + - name: Build image + run: | + cd ${{ matrix.directory }} + docker build . --file Dockerfile --tag ${{ matrix.image }} --label "latest" + - name: Push image + run: | + IMAGE_ID=ghcr.io/${{ github.repository }}/${{ matrix.image }} + # This changes all uppercase characters to lowercase. + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + echo IMAGE_ID=$IMAGE_ID + docker tag ${{ matrix.image }} $IMAGE_ID + docker push $IMAGE_ID diff --git a/kafka-java-console-sample/Dockerfile b/kafka-java-console-sample/Dockerfile index fbe28eb..e216719 100644 --- a/kafka-java-console-sample/Dockerfile +++ b/kafka-java-console-sample/Dockerfile @@ -1,11 +1,14 @@ -FROM gradle:jdk8-alpine as jdk +FROM gradle:jdk11-alpine as jdk COPY --chown=1000 . /usr/src/app WORKDIR /usr/src/app +COPY build.gradle settings.gradle /usr/src/app/ +COPY src /usr/src/app/src + RUN gradle -s --no-daemon assemble -FROM ibmjava:8-sfj-alpine +FROM openjdk:11 COPY --from=jdk /usr/src/app/build/libs/kafka-java-console-sample-2.0.jar /usr/src/app/ diff --git a/kafka-java-console-sample/docs/Local.md b/kafka-java-console-sample/docs/Local.md index 41b50bb..1efb55e 100644 --- a/kafka-java-console-sample/docs/Local.md +++ b/kafka-java-console-sample/docs/Local.md @@ -20,7 +20,7 @@ We will not discuss establishing a connection from your laptop to Event Streams 2. **If you don't already have them, install the following prerequisites:** * [git](https://git-scm.com/) - * [Gradle 7 of higher](https://gradle.org/) + * [Gradle 8 of higher](https://gradle.org/) * Java 8 or higher diff --git a/kafka-java-console-sample/kafka-java-console-sample.yaml b/kafka-java-console-sample/kafka-java-console-sample.yaml index 4251945..74a1aef 100644 --- a/kafka-java-console-sample/kafka-java-console-sample.yaml +++ b/kafka-java-console-sample/kafka-java-console-sample.yaml @@ -5,7 +5,7 @@ metadata: namespace: default spec: containers: - - image: ibmcom/kafka-java-console-sample:latest + - image: event-streams-samples/kafka-java-console-sample:latest imagePullPolicy: Always name: java-sample env: