Skip to content

Commit badbbe4

Browse files
committed
First commit
1 parent f0c6a82 commit badbbe4

20 files changed

+761
-0
lines changed

.github/workflows/main.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Main - Build, deploy to dev, deploy to prod
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
IMAGE: docker.pkg.github.com/${{ github.repository }}/kabal-smart-editor-api:${{ github.sha }}
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@master
17+
- name: Cache
18+
uses: actions/[email protected]
19+
with:
20+
path: ~/.gradle/caches
21+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
22+
restore-keys: |
23+
${{ runner.os }}-gradle-
24+
- name: Install Java 17
25+
uses: actions/setup-java@v1
26+
with:
27+
java-version: 17
28+
- name: test and build
29+
run: ./gradlew test bootJar
30+
env:
31+
ORG_GRADLE_PROJECT_githubUser: x-access-token
32+
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
33+
- name: Build docker image
34+
run: docker build -t $IMAGE .
35+
- name: Login to Github package registry
36+
run: docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN}
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
- name: Push docker image
40+
run: docker push $IMAGE
41+
- name: Post failures to Slack
42+
if: failure()
43+
run: |
44+
curl -X POST --data-urlencode "payload={\"channel\": \"$CHANNEL\", \"text\": \"$MESSAGE\", \"icon_emoji\": \":ghost:\"}" $WEBHOOK_URL
45+
env:
46+
MESSAGE: "Bygg feilet"
47+
CHANNEL: "#klage-notifications"
48+
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
49+
deploytodev:
50+
name: Deploy to dev
51+
needs: build
52+
if: github.ref == 'refs/heads/main'
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@master
56+
name: Checkout code
57+
- uses: nais/deploy/actions/deploy@master
58+
env:
59+
APIKEY: ${{ secrets.NAIS_DEPLOY_API_KEY }}
60+
CLUSTER: dev-gcp
61+
RESOURCE: deploy/nais.yaml
62+
VARS: deploy/dev.yaml
63+
- name: Post failures to Slack
64+
if: failure()
65+
run: |
66+
curl -X POST --data-urlencode "payload={\"channel\": \"$CHANNEL\", \"text\": \"$MESSAGE\", \"icon_emoji\": \":ghost:\"}" $WEBHOOK_URL
67+
env:
68+
MESSAGE: "Deploy til dev feilet"
69+
CHANNEL: "#klage-notifications"
70+
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
71+
deploytoprod:
72+
name: Deploy to prod
73+
needs: deploytodev
74+
if: github.ref == 'refs/heads/main'
75+
runs-on: ubuntu-latest
76+
steps:
77+
- uses: actions/checkout@master
78+
name: Checkout code
79+
- uses: nais/deploy/actions/deploy@master
80+
env:
81+
APIKEY: ${{ secrets.NAIS_DEPLOY_API_KEY }}
82+
CLUSTER: prod-gcp
83+
RESOURCE: deploy/nais.yaml
84+
VARS: deploy/prod.yaml
85+
- name: Generate release version
86+
run: |
87+
TIME=$(TZ="Europe/Oslo" date +%Y.%m.%d-%H.%M)
88+
COMMIT=$(git rev-parse --short=7 HEAD)
89+
VERSION=$TIME-$COMMIT
90+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
91+
- uses: actions/create-release@v1
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
with:
95+
tag_name: ${{ env.VERSION }}
96+
release_name: ${{ env.VERSION }}
97+
- name: Post failures to Slack
98+
if: failure()
99+
run: |
100+
curl -X POST --data-urlencode "payload={\"channel\": \"$CHANNEL\", \"text\": \"$MESSAGE\", \"icon_emoji\": \":ghost:\"}" $WEBHOOK_URL
101+
env:
102+
MESSAGE: "Deploy til prod feilet"
103+
CHANNEL: "#klage-notifications"
104+
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@navikt/klage

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM navikt/java:17
2+
3+
COPY build/libs/*.jar ./

build.gradle.kts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
val mockkVersion = "1.12.0"
4+
val logstashVersion = "6.6"
5+
val springVersion = "2.5.5"
6+
7+
repositories {
8+
mavenCentral()
9+
}
10+
11+
plugins {
12+
id("org.jetbrains.kotlin.jvm") version "1.5.31"
13+
id("org.springframework.boot") version "2.5.5"
14+
id("org.jetbrains.kotlin.plugin.spring") version "1.5.31"
15+
idea
16+
}
17+
18+
apply(plugin = "io.spring.dependency-management")
19+
20+
dependencies {
21+
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.5.31")
22+
23+
implementation("org.springframework.boot:spring-boot-starter-web:$springVersion")
24+
implementation("org.springframework.boot:spring-boot-starter-actuator:$springVersion")
25+
implementation("org.springframework.boot:spring-boot-starter-webflux:$springVersion")
26+
27+
// implementation("org.projectreactor:reactor-spring:1.0.1.RELEASE")
28+
29+
implementation("ch.qos.logback:logback-classic:1.2.6")
30+
implementation("net.logstash.logback:logstash-logback-encoder:$logstashVersion")
31+
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.0")
32+
33+
testImplementation("io.mockk:mockk:$mockkVersion")
34+
testImplementation("org.springframework:spring-mock:2.0.8")
35+
testImplementation("org.springframework.boot:spring-boot-starter-test:$springVersion")
36+
testImplementation("org.mockito:mockito-inline:3.12.4")
37+
}
38+
39+
tasks.withType<KotlinCompile> {
40+
kotlinOptions.jvmTarget = "11"
41+
}
42+
43+
tasks.withType<Test> {
44+
useJUnitPlatform()
45+
testLogging {
46+
events("passed", "skipped", "failed")
47+
}
48+
}
49+
50+
tasks.getByName<org.springframework.boot.gradle.tasks.bundling.BootJar>("bootJar") {
51+
this.archiveFileName.set("app.jar")
52+
}
53+
54+
kotlin.sourceSets["main"].kotlin.srcDirs("src/main/kotlin")
55+
kotlin.sourceSets["test"].kotlin.srcDirs("src/test/kotlin")
56+
57+
//sourceSets["main"].resources.srcDirs("src/main/resources")
58+
//sourceSets["test"].resources.srcDirs("src/test/resources")

deploy/dev.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ingresses:
2+
- https://kabal-smart-editor-api.dev.nav.no
3+
externalHosts:
4+
springProfile: dev-gcp

deploy/nais.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: "nais.io/v1alpha1"
2+
kind: "Application"
3+
metadata:
4+
name: kabal-smart-editor-api
5+
namespace: klage
6+
labels:
7+
team: klage
8+
annotations:
9+
nginx.ingress.kubernetes.io/proxy-body-size: "100M"
10+
nginx.ingress.kubernetes.io/proxy-read-timeout: "120"
11+
spec:
12+
image: {{ image }}
13+
port: 7095
14+
startup:
15+
failureThreshold: 20
16+
initialDelay: 30
17+
path: /internal/health
18+
periodSeconds: 10
19+
timeout: 2
20+
liveness:
21+
path: /internal/health
22+
initialDelay: 20
23+
timeout: 1
24+
periodSeconds: 5
25+
failureThreshold: 10
26+
readiness:
27+
path: /internal/health
28+
initialDelay: 20
29+
timeout: 1
30+
resources:
31+
limits:
32+
cpu: 2000m
33+
memory: 2048Mi
34+
requests:
35+
cpu: 400m
36+
memory: 256Mi
37+
ingresses:
38+
{{#each ingresses as |ingress|}}
39+
- {{ingress}}
40+
{{/each}}
41+
replicas:
42+
min: 2
43+
max: 4
44+
cpuThresholdPercentage: 80
45+
prometheus:
46+
enabled: true
47+
path: /internal/prometheus
48+
secureLogs:
49+
enabled: true
50+
accessPolicy:
51+
inbound:
52+
rules:
53+
- application: kabal-api
54+
env:
55+
- name: SPRING_PROFILES_ACTIVE
56+
value: {{springProfile}}

deploy/prod.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ingresses:
2+
- https://kabal-smart-editor-api.intern.nav.no
3+
externalHosts:
4+
springProfile: prod-gcp

gradle/wrapper/gradle-wrapper.jar

58.1 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
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-7.3-rc-1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)