-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/devsetting-bekreftelse-tjeneste'
- Loading branch information
Showing
36 changed files
with
1,539 additions
and
784 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: Bekreftelse Tjeneste | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev/* | ||
paths: | ||
- 'apps/bekreftelse-tjeneste/**' | ||
- 'lib/**' | ||
- 'domain/**' | ||
- '.github/workflows/bekreftelse-tjeneste.yaml' | ||
- 'gradle/**' | ||
- 'settings.gradle.kts' | ||
- 'gradle.properties' | ||
- 'gradlew' | ||
- 'gradlew.bat' | ||
|
||
env: | ||
MODULE: bekreftelse-tjeneste | ||
IMAGE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/paw/paw-arbeidssoekerregisteret-bekreftelse-tjeneste | ||
jobs: | ||
build: | ||
name: Build | ||
permissions: | ||
contents: read | ||
id-token: write | ||
packages: write | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image: ${{ steps.docker-build-push.outputs.image }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 21 | ||
distribution: temurin | ||
cache: gradle | ||
- name: Set version | ||
run: echo "VERSION=$(date +'%y.%m.%d').${{ github.run_number }}-${{ github.run_attempt }}" >> $GITHUB_ENV | ||
- name: Login GAR | ||
uses: nais/login@v0 | ||
with: | ||
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} | ||
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} | ||
team: paw | ||
- name: Build and push image with Gradle | ||
id: docker-build-push | ||
working-directory: ./ | ||
env: | ||
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo "image=${{ env.IMAGE }}:${{ env.VERSION }}" >> $GITHUB_OUTPUT | ||
echo -Pversion=${{ env.VERSION }} -Pimage=${{ env.IMAGE }} :apps:${{ env.MODULE }}:build :apps:${{ env.MODULE }}:jib | ||
./gradlew -Pversion=${{ env.VERSION }} -Pimage=${{ env.IMAGE }} :apps:${{ env.MODULE }}:build :apps:${{ env.MODULE }}:jib | ||
echo "DIGEST=$(cat ./apps/${{ env.MODULE }}/build/jib-image.digest)" >> $GITHUB_ENV | ||
- name: Attest and sign image | ||
uses: nais/[email protected] | ||
with: | ||
image_ref: ${{ env.IMAGE }}@${{ env.DIGEST }} | ||
|
||
deploy-dev: | ||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/dev') | ||
name: Deploy to dev-gcp | ||
needs: | ||
- build | ||
permissions: | ||
contents: read | ||
id-token: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Deploy to GCP | ||
uses: nais/deploy/actions/deploy@v2 | ||
env: | ||
CLUSTER: dev-gcp | ||
RESOURCE: ./apps/${{ env.MODULE }}/nais/nais-dev.yaml | ||
VAR: image=${{ needs.build.outputs.image }} | ||
|
||
# deploy-prod: | ||
# if: github.ref == 'refs/heads/main' | ||
# name: Deploy to prod-gcp | ||
# needs: | ||
# - build | ||
# - deploy-dev | ||
# permissions: | ||
# contents: read | ||
# id-token: write | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout | ||
# uses: actions/checkout@v4 | ||
# - name: Deploy to GCP | ||
# uses: nais/deploy/actions/deploy@v2 | ||
# env: | ||
# TEAM: paw | ||
# CLUSTER: prod-gcp | ||
# RESOURCE: ./apps/${{ env.MODULE }}/nais/nais-prod.yaml | ||
# VAR: image=${{ needs.build.outputs.image }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,78 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
kotlin("jvm") | ||
id("com.google.cloud.tools.jib") | ||
application | ||
} | ||
|
||
val jvmMajorVersion: String by project | ||
val baseImage: String by project | ||
val image: String? by project | ||
|
||
|
||
dependencies { | ||
// Project | ||
implementation(project(":lib:hoplite-config")) | ||
implementation(project(":lib:error-handling")) | ||
implementation(project(":lib:kafka-streams")) | ||
implementation(project(":lib:kafka-key-generator-client")) | ||
implementation(project(":domain:main-avro-schema")) | ||
implementation(project(":domain:bekreftelse-interne-hendelser")) | ||
implementation(project(":domain:bekreftelsesansvar-avro-schema")) | ||
implementation(project(":domain:bekreftelsesmelding-avro-schema")) | ||
implementation(libs.kafkaStreams) | ||
|
||
// Server | ||
implementation(libs.bundles.ktorServerWithNettyAndMicrometer) | ||
|
||
// Serialization | ||
implementation(libs.ktorSerializationJackson) | ||
implementation(libs.ktorSerializationJson) | ||
implementation(libs.jacksonDatatypeJsr310) | ||
implementation(libs.jacksonKotlin) | ||
implementation(libs.kafkaStreamsAvroSerde) | ||
|
||
// Tooling | ||
implementation(libs.arrowCore) | ||
implementation(libs.bundles.ktorServerWithNettyAndMicrometer) | ||
|
||
// Logging | ||
implementation(libs.logbackClassic) | ||
implementation(libs.logstashLogbackEncoder) | ||
implementation(libs.log) | ||
implementation(libs.auditLog) | ||
|
||
// Instrumentation | ||
implementation(libs.micrometerRegistryPrometheus) | ||
|
||
// Kafka | ||
implementation(libs.kafkaStreams) | ||
implementation(libs.kafkaStreamsAvroSerde) | ||
|
||
// Testing | ||
testImplementation(libs.ktorServerTestsJvm) | ||
testImplementation(libs.streamsTest) | ||
testImplementation(libs.runnerJunit5) | ||
testImplementation(libs.assertionsCore) | ||
testImplementation(libs.bundles.testLibsWithUnitTesting) | ||
testImplementation(project(":test:test-data-lib")) | ||
} | ||
|
||
//enable context receiver | ||
tasks.withType<KotlinCompile>().configureEach { | ||
compilerOptions { | ||
freeCompilerArgs.add("-Xcontext-receivers") | ||
java { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(jvmMajorVersion)) | ||
} | ||
} | ||
|
||
application { | ||
mainClass.set("no.nav.paw.bekreftelsetjeneste.ApplicationKt") | ||
} | ||
|
||
tasks.withType<Test>().configureEach { | ||
useJUnitPlatform() | ||
} | ||
|
||
jib { | ||
from.image = "$baseImage:$jvmMajorVersion" | ||
to.image = "${image ?: project.name}:${project.version}" | ||
container { | ||
environment = mapOf( | ||
"IMAGE_WITH_VERSION" to "${image ?: project.name}:${project.version}" | ||
) | ||
jvmFlags = listOf("-XX:ActiveProcessorCount=4", "-XX:+UseZGC", "-XX:+ZGenerational") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
apiVersion: nais.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: paw-arbeidssoekerregisteret-bekreftelse-tjeneste | ||
namespace: paw | ||
labels: | ||
team: paw | ||
spec: | ||
image: {{ image }} | ||
port: 8080 | ||
env: | ||
- name: KAFKA_STREAMS_ID_SUFFIX | ||
value: "v1" | ||
- name: KAFKA_PAW_ARBEIDSSOKER_BEKREFTELSE_TOPIC | ||
value: "paw.arbeidssoker-bekreftelse-beta-v1" | ||
- name: KAFKA_PAW_ARBEIDSSOKER_BEKREFTELSE_HENDELSELOGG_TOPIC | ||
value: "paw.arbeidssoker-bekreftelse-hendelseslogg-beta-v1" | ||
- name: KAFKA_PAW_ARBEIDSSOKERPERIODER_TOPIC | ||
value: "paw.arbeidssokerperioder-v1" | ||
- name: KAFKA_PUNCTUATOR_INTERVAL | ||
value: "PT1M" | ||
- name: BEKREFTELSE_INTERVAL | ||
value: "PT28M" | ||
- name: BEKREFTELSE_GRACEPERIODE | ||
value: "PT14M" | ||
- name: BEKREFTELSE_TILGJENGELIG_OFFSET | ||
value: "PT6M" | ||
|
||
replicas: | ||
min: 1 | ||
max: 1 | ||
resources: | ||
limits: | ||
memory: 1024Mi | ||
requests: | ||
cpu: 200m | ||
memory: 256Mi | ||
liveness: | ||
path: /internal/isAlive | ||
initialDelay: 10 | ||
readiness: | ||
path: /internal/isReady | ||
initialDelay: 10 | ||
prometheus: | ||
enabled: true | ||
path: /internal/metrics | ||
observability: | ||
autoInstrumentation: | ||
enabled: true | ||
runtime: java | ||
kafka: | ||
pool: nav-dev | ||
streams: true | ||
accessPolicy: | ||
outbound: | ||
rules: | ||
- application: paw-kafka-key-generator | ||
namespace: paw |
15 changes: 0 additions & 15 deletions
15
apps/bekreftelse-tjeneste/src/main/kotlin/no/nav/paw/bekreftelsetjeneste/AnsvarTopology.kt
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
apps/bekreftelse-tjeneste/src/main/kotlin/no/nav/paw/bekreftelsetjeneste/Application.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package no.nav.paw.bekreftelsetjeneste | ||
|
||
import io.ktor.server.application.Application | ||
import io.ktor.server.engine.addShutdownHook | ||
import io.ktor.server.engine.embeddedServer | ||
import io.ktor.server.netty.Netty | ||
import io.ktor.server.routing.routing | ||
import no.nav.paw.bekreftelsetjeneste.config.APPLICATION_CONFIG_FILE_NAME | ||
import no.nav.paw.bekreftelsetjeneste.config.ApplicationConfig | ||
import no.nav.paw.bekreftelsetjeneste.config.SERVER_CONFIG_FILE_NAME | ||
import no.nav.paw.bekreftelsetjeneste.config.ServerConfig | ||
import no.nav.paw.bekreftelsetjeneste.context.ApplicationContext | ||
import no.nav.paw.bekreftelsetjeneste.plugins.buildKafkaStreams | ||
import no.nav.paw.bekreftelsetjeneste.plugins.configureKafka | ||
import no.nav.paw.bekreftelsetjeneste.plugins.configureMetrics | ||
import no.nav.paw.bekreftelsetjeneste.routes.metricsRoutes | ||
import no.nav.paw.bekreftelsetjeneste.topology.buildTopology | ||
import no.nav.paw.config.env.appNameOrDefaultForLocal | ||
import no.nav.paw.config.env.currentRuntimeEnvironment | ||
import no.nav.paw.config.hoplite.loadNaisOrLocalConfiguration | ||
import no.nav.paw.health.route.healthRoutes | ||
import org.slf4j.LoggerFactory | ||
|
||
fun main() { | ||
val logger = LoggerFactory.getLogger("no.nav.paw.logger.application") | ||
|
||
val serverConfig = loadNaisOrLocalConfiguration<ServerConfig>(SERVER_CONFIG_FILE_NAME) | ||
val applicationConfig = loadNaisOrLocalConfiguration<ApplicationConfig>(APPLICATION_CONFIG_FILE_NAME) | ||
|
||
logger.info("Starter: ${currentRuntimeEnvironment.appNameOrDefaultForLocal()}") | ||
|
||
with(serverConfig) { | ||
embeddedServer(Netty, port = port) { | ||
module(applicationConfig) | ||
}.apply { | ||
addShutdownHook { stop(gracePeriodMillis, timeoutMillis) } | ||
start(wait = true) | ||
} | ||
} | ||
} | ||
|
||
fun Application.module(applicationConfig: ApplicationConfig) { | ||
val applicationContext = ApplicationContext.create(applicationConfig) | ||
|
||
val kafkaTopology = buildTopology(applicationContext) | ||
val kafkaStreams = buildKafkaStreams(applicationContext, kafkaTopology) | ||
|
||
configureMetrics(applicationContext) | ||
configureKafka(applicationContext, kafkaStreams) | ||
|
||
routing { | ||
healthRoutes(applicationContext.healthIndicatorRepository) | ||
metricsRoutes(applicationContext) | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
...telse-tjeneste/src/main/kotlin/no/nav/paw/bekreftelsetjeneste/ApplicationConfiguration.kt
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
...bekreftelse-tjeneste/src/main/kotlin/no/nav/paw/bekreftelsetjeneste/ApplicationContext.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.