diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 7cdcd8b..83f0fd1 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -17,6 +17,6 @@ jobs: uses: Informasjonsforvaltning/workflows/.github/workflows/codeql.yaml@main with: language: java - java_version: '17' + java_version: '21' secrets: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/deploy-prod&demo.yaml b/.github/workflows/deploy-prod&demo.yaml index f44a829..81db4e7 100644 --- a/.github/workflows/deploy-prod&demo.yaml +++ b/.github/workflows/deploy-prod&demo.yaml @@ -7,24 +7,35 @@ on: workflow_dispatch: jobs: - build-and-deploy-production: + build-fdk-dataset-preview-service: name: Deploy to prod on merge to main branch - uses: Informasjonsforvaltning/workflows/.github/workflows/build-deploy-maven.yaml@main + uses: Informasjonsforvaltning/workflows/.github/workflows/build-push.yaml@main + with: + app_name: fdk-dataset-preview-service + java_version: '21' + coverage_file_path: ./target/site/jacoco/jacoco.xml + environment: prod + secrets: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + deploy-prod: + name: Deploy to prod environment + needs: [ build-fdk-dataset-preview-service ] + uses: Informasjonsforvaltning/workflows/.github/workflows/kustomize-deploy.yaml@main with: app_name: fdk-dataset-preview-service - java_version: '17' environment: prod cluster: digdir-fdk-prod secrets: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GCP_SA_DIGDIR_FDK_GCR_KEY: ${{ secrets.GCP_SA_DIGDIR_FDK_GCR_KEY }} DIGDIR_FDK_AUTODEPLOY: ${{ secrets.DIGDIR_FDK_PROD_AUTODEPLOY }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} deploy-to-demo: - needs: build-and-deploy-production + needs: deploy-prod name: Deploy to demo if prod-deploy is successful - uses: Informasjonsforvaltning/workflows/.github/workflows/deploy.yaml@main + uses: Informasjonsforvaltning/workflows/.github/workflows/kustomize-deploy.yaml@main with: app_name: fdk-dataset-preview-service environment: demo diff --git a/.github/workflows/deploy-staging.yaml b/.github/workflows/deploy-staging.yaml index 927ea99..e945352 100644 --- a/.github/workflows/deploy-staging.yaml +++ b/.github/workflows/deploy-staging.yaml @@ -7,26 +7,36 @@ on: - main jobs: - build-and-deploy-staging: - name: Call reusable workflow when pull request is created + build-fdk-dataset-preview-service: + name: Build when pull request is created if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.draft == false }} - uses: Informasjonsforvaltning/workflows/.github/workflows/build-deploy-maven.yaml@main + uses: Informasjonsforvaltning/workflows/.github/workflows/build-push.yaml@main + with: + app_name: fdk-dataset-preview-service + java_version: '21' + coverage_file_path: ./target/site/jacoco/jacoco.xml + environment: staging + secrets: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + deploy-to-staging: + name: Deploy to staging environment + if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.draft == false }} + needs: [ build-fdk-dataset-preview-service ] + uses: Informasjonsforvaltning/workflows/.github/workflows/kustomize-deploy.yaml@main with: app_name: fdk-dataset-preview-service - java_version: '17' environment: staging cluster: digdir-fdk-dev secrets: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GCP_SA_DIGDIR_FDK_GCR_KEY: ${{ secrets.GCP_SA_DIGDIR_FDK_GCR_KEY }} DIGDIR_FDK_AUTODEPLOY: ${{ secrets.DIGDIR_FDK_DEV_AUTODEPLOY }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} dependabot-build: name: Build image on PR from dependabot - if: ${{ github.actor == 'dependabot[bot]' }} + if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }} uses: Informasjonsforvaltning/workflows/.github/workflows/build.yaml@main with: - java_version: '17' - secrets: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + java_version: '21' diff --git a/Dockerfile b/Dockerfile index 29349f9..20fc4f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM maven:3-openjdk-17-slim AS build +FROM maven:3.9.9-eclipse-temurin-21-jammy AS build WORKDIR /app COPY pom.xml ./ COPY src ./src RUN mvn clean package --no-transfer-progress -DskipTests RUN mvn versions:display-dependency-updates --no-transfer-progress -FROM eclipse-temurin:17-jre-jammy +FROM eclipse-temurin:21-jre-jammy ENV TZ=Europe/Oslo RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone WORKDIR /app diff --git a/deploy/base/fdk-dataset-preview-service-deployment.yaml b/deploy/base/fdk-dataset-preview-service-deployment.yaml new file mode 100644 index 0000000..92d7185 --- /dev/null +++ b/deploy/base/fdk-dataset-preview-service-deployment.yaml @@ -0,0 +1,48 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + fdk.service: fdk-dataset-preview-service + name: fdk-dataset-preview-service +spec: + replicas: 1 + selector: + matchLabels: + fdk.service: fdk-dataset-preview-service + strategy: + type: RollingUpdate + template: + metadata: + labels: + fdk.service: fdk-dataset-preview-service + spec: + containers: + - name: fdk-dataset-preview-service + image: fdk-dataset-preview-service + imagePullPolicy: Always + ports: + - containerPort: 8080 + resources: + requests: + memory: "750Mi" + cpu: "10m" + limits: + memory: "750Mi" + livenessProbe: + httpGet: + path: /ping + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 30 + successThreshold: 1 + failureThreshold: 5 + readinessProbe: + httpGet: + path: /ready + port: 8080 + initialDelaySeconds: 150 + periodSeconds: 30 + successThreshold: 1 + failureThreshold: 5 + restartPolicy: Always diff --git a/deploy/base/fdk-dataset-preview-service-service.yaml b/deploy/base/fdk-dataset-preview-service-service.yaml new file mode 100644 index 0000000..0177e9c --- /dev/null +++ b/deploy/base/fdk-dataset-preview-service-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + fdk.service: fdk-dataset-preview-service + name: fdk-dataset-preview-service +spec: + type: NodePort + ports: + - name: "8080" + port: 8080 + targetPort: 8080 + selector: + fdk.service: fdk-dataset-preview-service diff --git a/deploy/base/kustomization.yaml b/deploy/base/kustomization.yaml new file mode 100644 index 0000000..fad9e48 --- /dev/null +++ b/deploy/base/kustomization.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - fdk-dataset-preview-service-deployment.yaml + - fdk-dataset-preview-service-service.yaml +images: + - name: fdk-dataset-preview-service + newName: ghcr.io/informasjonsforvaltning/fdk-dataset-preview-service + newTag: $(GIT_COMMIT_SHA) diff --git a/deploy/demo/env.yaml b/deploy/demo/env.yaml new file mode 100644 index 0000000..e59a0e9 --- /dev/null +++ b/deploy/demo/env.yaml @@ -0,0 +1,28 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: fdk-dataset-preview-service + labels: + app: fdk-dataset-preview-service +spec: + template: + spec: + containers: + - name: fdk-dataset-preview-service + env: + - name: NAMESPACE + valueFrom: + secretKeyRef: + name: common-demo + key: NAMESPACE + - name: API_KEY + valueFrom: + secretKeyRef: + name: common-demo + key: FDK_DATASET_PREVIEW_API_KEY + - name: ALLOWED_ORIGINS + valueFrom: + secretKeyRef: + name: common-demo + key: FDK_DATASET_PREVIEW_ALLOWED_ORIGINS diff --git a/deploy/demo/kustomization.yaml b/deploy/demo/kustomization.yaml new file mode 100644 index 0000000..83f2c77 --- /dev/null +++ b/deploy/demo/kustomization.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: demo +resources: + - ../base + +patches: + - path: env.yaml diff --git a/deploy/prod/env.yaml b/deploy/prod/env.yaml new file mode 100644 index 0000000..156c440 --- /dev/null +++ b/deploy/prod/env.yaml @@ -0,0 +1,28 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: fdk-dataset-preview-service + labels: + app: fdk-dataset-preview-service +spec: + template: + spec: + containers: + - name: fdk-dataset-preview-service + env: + - name: NAMESPACE + valueFrom: + secretKeyRef: + name: common-prod + key: NAMESPACE + - name: API_KEY + valueFrom: + secretKeyRef: + name: common-prod + key: FDK_DATASET_PREVIEW_API_KEY + - name: ALLOWED_ORIGINS + valueFrom: + secretKeyRef: + name: common-prod + key: FDK_DATASET_PREVIEW_ALLOWED_ORIGINS diff --git a/deploy/prod/kustomization.yaml b/deploy/prod/kustomization.yaml new file mode 100644 index 0000000..913810f --- /dev/null +++ b/deploy/prod/kustomization.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: prod +resources: + - ../base + +patches: + - path: env.yaml diff --git a/deploy/staging/env.yaml b/deploy/staging/env.yaml new file mode 100644 index 0000000..5be69b9 --- /dev/null +++ b/deploy/staging/env.yaml @@ -0,0 +1,28 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: fdk-dataset-preview-service + labels: + app: fdk-dataset-preview-service +spec: + template: + spec: + containers: + - name: fdk-dataset-preview-service + env: + - name: NAMESPACE + valueFrom: + secretKeyRef: + name: common-staging + key: NAMESPACE + - name: API_KEY + valueFrom: + secretKeyRef: + name: common-staging + key: FDK_DATASET_PREVIEW_API_KEY + - name: ALLOWED_ORIGINS + valueFrom: + secretKeyRef: + name: common-staging + key: FDK_DATASET_PREVIEW_ALLOWED_ORIGINS diff --git a/deploy/staging/kustomization.yaml b/deploy/staging/kustomization.yaml new file mode 100644 index 0000000..71c8924 --- /dev/null +++ b/deploy/staging/kustomization.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: staging +resources: + - ../base + +patches: + - path: env.yaml diff --git a/pom.xml b/pom.xml index d5c138f..56aa612 100644 --- a/pom.xml +++ b/pom.xml @@ -12,21 +12,21 @@ org.springframework.boot spring-boot-starter-parent - 3.3.3 + 3.4.0 - 17 + 21 UTF-8 UTF-8 UTF-8 ${java.release} ${java.release} - 2.0.20 - 5.1.0 - 2.17.2 + 2.1.0 + 5.2.0 + 2.18.2 @@ -95,7 +95,7 @@ org.apache.commons commons-csv - 1.11.0 + 1.12.0 @@ -113,7 +113,7 @@ org.apache.tika tika-core - 2.9.2 + 3.0.0 @@ -137,13 +137,13 @@ org.wiremock wiremock-standalone - 3.9.1 + 3.9.2 test org.apache.httpcomponents.client5 httpclient5 - 5.3.1 + 5.4.1 test @@ -155,7 +155,7 @@ commons-io commons-io - 2.16.1 + 2.18.0 compile @@ -224,7 +224,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.0 + 3.5.2 false unit @@ -237,7 +237,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.5.0 + 3.5.2 integration unit