Skip to content

Commit

Permalink
Merge branch 'feature/toml'
Browse files Browse the repository at this point in the history
  • Loading branch information
geiralund committed Oct 2, 2023
2 parents f76ae88 + 881cd9f commit 38271d6
Show file tree
Hide file tree
Showing 124 changed files with 3,161 additions and 2,498 deletions.
74 changes: 31 additions & 43 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,67 +1,53 @@
name: Build and deploy

on:
push:
branches-ignore:
- 'dependabot/**'
env:
IMAGE: ghcr.io/${{ github.repository }}/dp-mottak:${{ github.sha }}


jobs:
build:
name: Build and publish Docker image
runs-on: ubuntu-latest
permissions:
permissions: # Sjekk https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
contents: read
packages: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
distribution: 'temurin'

- name: Setup gradle dependency cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', 'buildSrc/src/main/kotlin/Constants.kt') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle
run: ./gradlew build --info

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
- uses: gradle/[email protected]
- uses: gradle/[email protected]
env:
# Eksluder test dependencies
DEPENDENCY_GRAPH_INCLUDE_CONFIGURATIONS: compileClasspath|runtimeClasspath
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
gradle-version: wrapper
dependency-graph: generate-and-submit
arguments: --configuration-cache build installDist

- name: Build and push
uses: docker/build-push-action@v4
- name: docker-build-push
uses: nais/docker-build-push@v0
if: github.ref == 'refs/heads/feature/toml'
id: docker-build-push
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
tags: ${{ env.IMAGE }},${{ env.LATEST_IMAGE }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
byosbom: dependency-graph-reports/build_and_deploy-build.json
team: teamdagpenger
push_image: true # optional, default true
tag: ${{ github.sha }}
dockerfile: mediator/Dockerfile # optional, default Dockerfile
docker_context: mediator # optional, default .
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
outputs:
image: ${{ steps.docker-build-push.outputs.image }}

deploy-dev:
name: Deploy to dev
needs: [build]
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/feature/toml'
runs-on: ubuntu-latest
environment: dev-gcp
steps:
Expand All @@ -71,6 +57,7 @@ jobs:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: .nais/nais.yaml
VAR: image=${{ needs.build.outputs.image }}
VARS: .nais/dev-vars.yaml
PRINT_PAYLOAD: true

Expand All @@ -87,5 +74,6 @@ jobs:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: .nais/nais.yaml
VAR: image=${{ needs.build.outputs.image }}
VARS: .nais/prod-vars.yaml
PRINT_PAYLOAD: true
2 changes: 1 addition & 1 deletion .nais/dev-vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ replicas_min: 2
replicas_max: 2
point_in_time_recovery_days: 2
ingresses:
- "https://dp-mottak.dev.intern.nav.no/"
- "https://dp-mottak.intern.dev.nav.no/"
3 changes: 0 additions & 3 deletions Dockerfile

This file was deleted.

10 changes: 3 additions & 7 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
plugins {
`kotlin-dsl`
kotlin("jvm") version "1.9.10"
id("com.diffplug.spotless") version "6.22.0"
}

repositories {
gradlePluginPortal()
mavenCentral()
}

dependencies {
implementation(kotlin("gradle-plugin"))
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.21.0")
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.22.0")
}

kotlin {
jvmToolchain(17)
}

6 changes: 0 additions & 6 deletions buildSrc/settings.gradle.kts

This file was deleted.

15 changes: 0 additions & 15 deletions buildSrc/src/main/kotlin/DependencyResolver.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import com.diffplug.spotless.LineEnding
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm")
id("dagpenger.spotless")
id("com.diffplug.spotless")
}

repositories {
mavenCentral()
maven {
url = uri("https://github-package-registry-mirror.gc.nav.no/cached/maven-release")
}
}

dependencies {
implementation(platform(kotlin("bom")))
implementation(kotlin("stdlib-jdk8"))
testImplementation(kotlin("test"))
}

testImplementation(Junit5.api)
testRuntimeOnly(Junit5.engine)
kotlin {
jvmToolchain(17)
}

tasks.test {
Expand All @@ -28,8 +34,17 @@ tasks.test {
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
}
}
kotlin {
jvmToolchain(17)
}

configure<com.diffplug.gradle.spotless.SpotlessExtension> {
kotlin {
ktlint()
}

kotlinGradle {
ktlint()
}
}

tasks.withType<KotlinCompile>().configureEach {
dependsOn("spotlessApply")
}
28 changes: 0 additions & 28 deletions buildSrc/src/main/kotlin/dagpenger.rapid-and-rivers.gradle.kts

This file was deleted.

19 changes: 0 additions & 19 deletions buildSrc/src/main/kotlin/dagpenger.spotless.gradle.kts

This file was deleted.

2 changes: 1 addition & 1 deletion .dockerignore → mediator/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
**

# Except build jar
!mediator/build/libs/*.jar
!build/install/**
24 changes: 24 additions & 0 deletions mediator/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM eclipse-temurin:17 as jre-build

# Create a custom Java runtime
RUN $JAVA_HOME/bin/jlink \
--add-modules ALL-MODULE-PATH \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime

# Runtime
FROM debian:buster-slim

ENV LANG='nb_NO.UTF-8' LANGUAGE='nb_NO:nb' LC_ALL='nb:NO.UTF-8' TZ="Europe/Oslo"
ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"

COPY --from=jre-build /javaruntime $JAVA_HOME

COPY build/install/* /

USER nobody
CMD ["mediator"]
43 changes: 21 additions & 22 deletions mediator/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
plugins {
id("dagpenger.rapid-and-rivers")
id("common")
application
}

repositories {
maven("https://jitpack.io")
}

application {
Expand All @@ -8,29 +13,23 @@ application {

dependencies {
implementation(project(":modell"))
implementation("com.github.navikt.dp-biblioteker:oauth2-klient:2022.10.22-09.05.6fcf3395aa4f")
implementation(Database.Flyway)
implementation(Database.HikariCP)
implementation(Database.Kotlinquery)
implementation(Database.Postgres)
implementation(libs.dp.biblioteker.oauth2.klient)

implementation(libs.rapids.and.rivers)

implementation(libs.bundles.postgres)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.6.0")
implementation(Jackson.core)
implementation(Jackson.jsr310)
implementation(Jackson.kotlin)
implementation(Ktor2.Client.library("cio"))
implementation(Ktor2.Client.library("content-negotiation"))
implementation("io.ktor:ktor-serialization-jackson:${Ktor2.version}")
implementation(Ktor2.Server.library("auth"))
implementation(Ktor2.Server.library("auth-jwt"))
implementation(Ktor2.Server.library("status-pages"))
implementation(Ktor2.Server.library("content-negotiation"))
implementation(Ktor2.Server.library("call-logging"))

implementation(libs.bundles.jackson)

implementation(libs.bundles.ktor.server)
implementation(libs.bundles.ktor.client)
implementation("de.slub-dresden:urnlib:2.0.1")

testImplementation(kotlin("test"))
testImplementation("no.nav.security:mock-oauth2-server:1.0.0")
testImplementation(Mockk.mockk)
testImplementation(TestContainers.postgresql)
testImplementation(Junit5.params)
testImplementation(Ktor2.Server.library("test-host"))
testImplementation("org.junit.jupiter:junit-jupiter-params:${libs.versions.junit.get()}")
testImplementation(libs.mockk)
testImplementation(libs.mock.oauth2.server)
testImplementation(libs.bundles.postgres.test)
testImplementation("io.ktor:ktor-server-test-host-jvm:${libs.versions.ktor.get()}")
}
Loading

0 comments on commit 38271d6

Please sign in to comment.