Skip to content

Commit

Permalink
Add CI for build and publish docker Images (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
raminqaf authored Dec 12, 2024
1 parent 3fef629 commit c28564d
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 28 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/build-and-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build and Publish

on:
push:
tags: ["**"]
branches: ["**"]

env:
java-version: 21
gradle-version: 8.4
working-directory: "./word-count/code"

jobs:
build-and-test:
name: Build, Test and Assess code quality
uses: bakdata/ci-templates/.github/workflows/[email protected]
with:
java-version: 21
gradle-version: 8.4
gradle-cache: true
gradle-cache-read-only: false
gradle-refresh-dependencies: false
working-directory: "./word-count/code"
secrets:
signing-key-id: ${{ secrets.SONATYPE_SIGNING_KEY_ID }}
signing-password: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}
signing-secret-key-ring: ${{ secrets.SONATYPE_SIGNING_SECRET_KEY_RING }}
sonar-token: ${{ secrets.SONARCLOUD_TOKEN }}
sonar-organization: ${{ secrets.SONARCLOUD_ORGANIZATION }}

build-jib:
name: Build images
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ${{ env.working-directory }}
needs: build-and-test

steps:
- name: Login into docker
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push sentence producer image
uses: bakdata/ci-templates/actions/[email protected]
with:
full-image-name: bakdata/kpops-demo-sentence-producer
class: com.bakdata.kpops.examples.SentenceProducer
java-version: ${{ env.java-version }}
gradle-version: ${{ env.gradle-version }}
gradle-cache: true
gradle-cache-read-only: true
gradle-refresh-dependencies: false
working-directory: ${{ env.working-directory }}

- name: Build and push word count image
uses: bakdata/ci-templates/actions/[email protected]
with:
full-image-name: bakdata/kpops-demo-word-count-app
class: com.bakdata.kpops.examples.WordCountApplication
java-version: ${{ env.java-version }}
gradle-version: ${{ env.gradle-version }}
gradle-cache: true
gradle-cache-read-only: true
gradle-refresh-dependencies: false
working-directory: ${{ env.working-directory }}
27 changes: 27 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release

on:
workflow_dispatch:
inputs:
release-type:
description: "The scope of the release (major, minor or patch)."
type: choice
required: true
default: patch
options:
- patch
- minor
- major

jobs:
java-gradle-release:
name: Java Gradle Release
uses: bakdata/ci-templates/.github/workflows/[email protected]
with:
java-version: 21
release-type: "${{ inputs.release-type }}"
working-directory: "./word-count/code"
secrets:
github-email: "${{ secrets.GH_EMAIL }}"
github-username: "${{ secrets.GH_USERNAME }}"
github-token: ${{ secrets.GH_TOKEN }}
2 changes: 1 addition & 1 deletion word-count/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ gradle jib -Djib.to.image=bakdata/kpops-demo-sentence-producer -Djib.container.m


# deploy streams-app
gradle jib -Djib.to.image=bakdata/kpops-demo-word-count-app-Djib.container.mainClass=com.bakdata.kpops.examples.WordCountApplication
gradle jib -Djib.to.image=bakdata/kpops-demo-word-count-app -Djib.container.mainClass=com.bakdata.kpops.examples.WordCountApplication
```
13 changes: 13 additions & 0 deletions word-count/code/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
description = "Word count pipeline with Kafka Streams"

plugins {
java
idea
id("com.bakdata.release") version "1.4.1"
id("com.bakdata.sonar") version "1.4.1"
id("com.bakdata.sonatype") version "1.4.1"
id("io.freefair.lombok") version "8.11"
id("com.google.cloud.tools.jib") version "3.4.4"
}
Expand All @@ -20,6 +24,15 @@ java {
}
}

configure<com.bakdata.gradle.SonatypeSettings> {
developers {
developer {
name.set("Ramin Gharib")
id.set("raminqaf")
}
}
}

tasks {
compileJava {
options.encoding = "UTF-8"
Expand Down
Binary file added word-count/code/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion word-count/code/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions word-count/code/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions word-count/code/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
4 changes: 0 additions & 4 deletions word-count/code/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven {
name "JCenter Gradle Plugins"
url "https://dl.bintray.com/gradle/gradle-plugins"
}
}
}

Expand Down
7 changes: 3 additions & 4 deletions word-count/deployment/values-dataproducer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ nameOverride: word-count-data-producer
replicaCount: 1

image: bakdata/kpops-demo-sentence-producer
imageTag: 1.0.0
imageTag: 2.0.0
imagePullPolicy: Always
streams:
brokers: "k8kafka-cp-kafka-headless:9092"
kafka:
bootstrapServers: "k8kafka-cp-kafka-headless:9092"
outputTopic: word-count-raw-data-producer-topic
prometheus:
jmx:
enabled: false

debug: true
9 changes: 3 additions & 6 deletions word-count/deployment/values-wordcounter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@ nameOverride: word-count-wordcounter
replicaCount: 1

image: bakdata/kpops-demo-word-count-app
imageTag: 1.0.0
imageTag: 2.0.0
imagePullPolicy: Always

streams:
brokers: "k8kafka-cp-kafka-headless:9092"
kafka:
bootstrapServers: "k8kafka-cp-kafka-headless:9092"
inputTopics: word-count-raw-data-producer-topic
outputTopic: word-count-countedwords-topic
productive: false

annotations:
consumerGroup: "word-counter-group"

prometheus:
jmx:
enabled: false

debug: true

0 comments on commit c28564d

Please sign in to comment.