From 097d35a97ee5e91828365877043b4d6c47c822b6 Mon Sep 17 00:00:00 2001 From: Christian Thiel Date: Mon, 19 Aug 2024 16:21:02 +0200 Subject: [PATCH] #15 build docker image in pipeline --- .github/workflows/build-gradle.yml | 8 +++++-- backend/build.gradle.kts | 5 +++++ frontend/build.gradle.kts | 34 ++++++++++++++++++++++++++++++ settings.gradle.kts | 1 + 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 frontend/build.gradle.kts diff --git a/.github/workflows/build-gradle.yml b/.github/workflows/build-gradle.yml index 2377c71..90909ff 100644 --- a/.github/workflows/build-gradle.yml +++ b/.github/workflows/build-gradle.yml @@ -15,10 +15,14 @@ jobs: java-version: '17' - name: Setup Gradle uses: gradle/gradle-build-action@v2 - - name: Build + - name: Build Frontend + run: ./gradlew frontend:appNpmBuild + - name: Build Backend run: ./gradlew build -x test - name: Test run: ./gradlew test jacocoTestReport + - name: Build Image + run: ./gradlew jibDockerBuild - name: Test Results uses: dorny/test-reporter@v1 if: always() @@ -50,4 +54,4 @@ jobs: with: name: code-coverage-report-markdown path: '*/coverage-results.md' - retention-days: 1 \ No newline at end of file + retention-days: 1 diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index c846610..bcd2be7 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -67,6 +67,7 @@ dependencies { } tasks.withType { + dependsOn(":frontend:appNpmBuild") kotlinOptions { freeCompilerArgs = listOf("-Xjsr305=strict") jvmTarget = "17" @@ -97,6 +98,10 @@ jib { architecture = "arm64" os = "linux" } + platform { + architecture = "amd64" + os = "linux" + } } } to { diff --git a/frontend/build.gradle.kts b/frontend/build.gradle.kts new file mode 100644 index 0000000..2d35e6e --- /dev/null +++ b/frontend/build.gradle.kts @@ -0,0 +1,34 @@ +import com.moowork.gradle.node.npm.NpmTask + + +plugins { + id("com.github.node-gradle.node") version "2.2.2" + //id("com.github.node-gradle.node") version "7.0.2" +} + +group = "org.quizmania" +version = "0.0.1-SNAPSHOT" + +tasks.register("appNpmInstall") { + description = "Installs all dependencies from package.json" + workingDir = file("${project.projectDir}/src/main/webapp") + args = listOf("install") +} + + +tasks.register("appNpmBuild") { + dependsOn("appNpmInstall") + description = "Builds project" + workingDir = file("${project.projectDir}/src/main/webapp") + args = listOf("run", "build") +} + +node { + download = true + version = "20.16.0" + npmVersion = "10.8.2" + // Set the work directory for unpacking node + workDir = file("${project.buildDir}/nodejs") + // Set the work directory for NPM + npmWorkDir = file("${project.buildDir}/npm") +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 9009b75..e69b8f7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,4 @@ rootProject.name = "quizmania" include(":backend") +include(":frontend")