Skip to content

Commit af9fd43

Browse files
committed
Init Kotlin-ktor base application with Naiserator
1 parent 16d534e commit af9fd43

19 files changed

+776
-1
lines changed

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Idea project files
2+
*.iml
3+
.idea/
4+
5+
# Gradle files
6+
out/
7+
build/
8+
.gradle/
9+
10+
# Generated sources
11+
src/generated
12+
13+
# OS specific
14+
.DS_Store
15+
16+
# Local environment
17+
localEnv.json

CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @navikt/digisyfo

Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM navikt/java:11
2+
COPY build/libs/syfooversiktsrv-*-all.jar app.jar
3+
ENV JAVA_OPTS="-Dlogback.configurationFile=logback-remote.xml"
4+
ENV APPLICATION_PROFILE="remote"

Jenkinsfile

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env groovy
2+
3+
import java.text.SimpleDateFormat
4+
5+
pipeline {
6+
agent any
7+
8+
environment {
9+
APPLICATION_NAME = 'syfooversiktsrv'
10+
}
11+
12+
stages {
13+
stage('initialize') {
14+
steps {
15+
script {
16+
sh './gradlew clean'
17+
def date = new Date()
18+
def dateFormat = new SimpleDateFormat("dd.MM.HHmm")
19+
env.COMMIT_HASH_SHORT = "${env.GIT_COMMIT}"[0..6]
20+
env.APPLICATION_VERSION = dateFormat.format(date) + "-${env.COMMIT_HASH_SHORT}"
21+
}
22+
}
23+
}
24+
stage('build') {
25+
steps {
26+
sh './gradlew build -x test'
27+
}
28+
}
29+
stage('run tests (unit & intergration)') {
30+
steps {
31+
sh './gradlew test'
32+
}
33+
}
34+
stage('create uber jar') {
35+
steps {
36+
sh './gradlew shadowJar'
37+
}
38+
}
39+
stage('push docker image') {
40+
steps {
41+
script {
42+
docker.withRegistry('https://repo.adeo.no:5443', 'nexus-credentials') {
43+
def image = docker.build("syfo/${APPLICATION_NAME}:${APPLICATION_VERSION}", "--pull --build-arg GIT_COMMIT_ID=${env.COMMIT_HASH_SHORT} --build-arg http_proxy=http://webproxy-internett.nav.no:8088 --build-arg https_proxy=http://webproxy-internett.nav.no:8088 .")
44+
image.push()
45+
}
46+
}
47+
}
48+
}
49+
stage('update version in naiserator.yaml') {
50+
steps {
51+
script {
52+
withEnv(['HTTPS_PROXY=http://webproxy-internett.nav.no:8088']) {
53+
withCredentials([string(credentialsId: 'OAUTH_TOKEN', variable: 'token')]) {
54+
def naiseratorFile = sh(script: "curl -s https://${token}@raw.githubusercontent.com/navikt/syfonais/master/preprod-fss/syfooversiktsrv/naiserator.yaml", returnStdout: true).trim()
55+
writeFile file: "naiserator.yaml", text: naiseratorFile
56+
def payload = readFile('naiserator.yaml').replaceAll("@@version@@", env.APPLICATION_VERSION)
57+
writeFile file: "naiserator.yaml", text: payload
58+
}
59+
}
60+
}
61+
}
62+
}
63+
64+
stage('deploy to preprod') {
65+
steps {
66+
script {
67+
withCredentials([file(credentialsId: env.KUBECONFIG ?: 'kubeconfig', variable: 'KUBECONFIG')]) {
68+
sh 'kubectl apply --context preprod-fss --namespace default -f naiserator.yaml'
69+
sh 'kubectl --context preprod-fss --namespace default rollout status -w deployment/${APPLICATION_NAME}'
70+
}
71+
}
72+
}
73+
}
74+
}
75+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 NAV (Arbeids- og velferdsdirektoratet) - The Norwegian Labour and Welfare Administration
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
# syfooversiktsrv
2-
Backend-tjenester for syfooversikt
2+
Denne appen er en backend-tjenste for Syfooversikt
3+
4+
## Bygge og kjøre appen lokalt
5+
1. Kjør `./gradlew clean shadowJar`
6+
2. Lag en kopi av `localEnvForTests.json` som du gir navnet `localEnv.json` og legg inn riktige verdier. Denne filen ignoreres av git.
7+
Husk å oppdatere med riktig filsti i Environment.kt: `const val localEnvironmentPropertiesPath = "./src/main/resources/localEnv.json"`
8+
2. Bygg dockerimage og start appen med `docker build -t app_name .` og
9+
`docker run -p 8080:8080 syfooversiktsrv`

build.gradle

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
buildscript {
2+
ext.coroutines_version = '1.2.1'
3+
ext.kluent_version = '1.39'
4+
ext.ktor_version = '1.2.0'
5+
ext.logback_version = '1.2.3'
6+
ext.prometheus_version = '0.5.0'
7+
ext.spek_version = "2.0.4"
8+
ext.logstash_encoder_version = '5.1'
9+
ext.jackson_version='2.9.8'
10+
}
11+
12+
plugins {
13+
id 'org.jetbrains.kotlin.jvm' version '1.3.21'
14+
id("com.diffplug.gradle.spotless") version "3.14.0"
15+
id("com.github.johnrengelman.shadow") version "4.0.3"
16+
}
17+
18+
group 'no.nav.syfo'
19+
version '1.0-SNAPSHOT'
20+
21+
jar.manifest.attributes("Main-Class" : "no.nav.syfo.BootstrapKt")
22+
23+
repositories {
24+
mavenCentral()
25+
jcenter()
26+
maven { url "https://dl.bintray.com/kotlin/ktor" }
27+
maven { url 'https://repo.adeo.no/repository/maven-releases/' }
28+
maven { url "https://dl.bintray.com/spekframework/spek-dev" }
29+
}
30+
31+
test {
32+
useJUnitPlatform {
33+
includeEngines 'spek2'
34+
}
35+
testLogging {
36+
showStandardStreams = true
37+
}
38+
}
39+
40+
dependencies {
41+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
42+
43+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
44+
implementation "io.ktor:ktor-metrics-micrometer:$ktor_version"
45+
implementation "io.micrometer:micrometer-registry-prometheus:1.1.4"
46+
implementation "io.ktor:ktor-server-netty:$ktor_version"
47+
implementation "io.ktor:ktor-client-apache:$ktor_version"
48+
implementation "io.ktor:ktor-client-logging:$ktor_version"
49+
implementation "io.ktor:ktor-client-logging-jvm:$ktor_version"
50+
51+
implementation "ch.qos.logback:logback-classic:$logback_version"
52+
implementation "net.logstash.logback:logstash-logback-encoder:$logstash_encoder_version"
53+
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
54+
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:$jackson_version"
55+
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
56+
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.9.0"
57+
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.9.0"
58+
59+
compile "io.ktor:ktor-jackson:$ktor_version"
60+
compile "io.ktor:ktor-client-jackson:$ktor_version"
61+
compile "io.ktor:ktor-auth:$ktor_version"
62+
compile "io.ktor:ktor-auth-jwt:$ktor_version"
63+
64+
testImplementation "org.amshove.kluent:kluent:$kluent_version"
65+
testImplementation "org.spekframework.spek2:spek-dsl-jvm:$spek_version"
66+
testImplementation "io.ktor:ktor-server-test-host:$ktor_version"
67+
68+
testRuntimeOnly "org.spekframework.spek2:spek-runtime-jvm:$spek_version"
69+
testRuntimeOnly "org.spekframework.spek2:spek-runner-junit5:$spek_version"
70+
71+
api "io.ktor:ktor-client-mock:$ktor_version"
72+
api "io.ktor:ktor-client-mock-jvm:$ktor_version"
73+
}
74+
75+
compileKotlin {
76+
kotlinOptions.jvmTarget = "1.8"
77+
}
78+
79+
compileTestKotlin {
80+
kotlinOptions.jvmTarget = "1.8"
81+
}
82+
83+
task printVersion() {
84+
doLast {
85+
println(version)
86+
}
87+
}

gradle/wrapper/gradle-wrapper.jar

53.1 KB
Binary file not shown.
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)