From f09668e2fc663089867c06221a5e07e5be8240eb Mon Sep 17 00:00:00 2001 From: Nitya Tadepalli Date: Tue, 23 Jan 2024 22:09:01 -0500 Subject: [PATCH 1/2] adding kafka-java-console-sample workflow --- .github/workflows/docker-image.yml | 43 +++++++++++++++++++ kafka-java-console-sample/Dockerfile | 5 ++- kafka-java-console-sample/docs/Local.md | 2 +- .../kafka-java-console-sample.yaml | 2 +- 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..c07346d --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,43 @@ +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: Run bash script + #run: bash ${{ matrix.script }} + - 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..c906afa 100644 --- a/kafka-java-console-sample/Dockerfile +++ b/kafka-java-console-sample/Dockerfile @@ -1,8 +1,11 @@ -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 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: From d75c640601c267d57ede877deb387a92f3507bcb Mon Sep 17 00:00:00 2001 From: Nitya Tadepalli Date: Wed, 24 Jan 2024 12:32:28 -0500 Subject: [PATCH 2/2] address comments --- .github/workflows/docker-image.yml | 2 -- kafka-java-console-sample/Dockerfile | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index c07346d..a03961a 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -27,8 +27,6 @@ jobs: - name: Log in to registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - #- name: Run bash script - #run: bash ${{ matrix.script }} - name: Build image run: | cd ${{ matrix.directory }} diff --git a/kafka-java-console-sample/Dockerfile b/kafka-java-console-sample/Dockerfile index c906afa..e216719 100644 --- a/kafka-java-console-sample/Dockerfile +++ b/kafka-java-console-sample/Dockerfile @@ -8,7 +8,7 @@ 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/