Skip to content

Commit dd9dfa5

Browse files
Bytter til distroless image og endrer til docker-build-push for å generere sbom ved bygging (#613)
* bytter til distroless image * bytter til docker-build-push for å generere sbom
1 parent 53cfd56 commit dd9dfa5

File tree

3 files changed

+30
-44
lines changed

3 files changed

+30
-44
lines changed

.github/workflows/master.yml

+13-20
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ env:
1212

1313
jobs:
1414
# Label of the container job
15-
build:
15+
build_and_deploy:
1616
# You must use a Linux environment when using service containers or container jobs
1717
runs-on: ubuntu-latest
1818
permissions:
19-
packages: write
19+
contents: read
20+
id-token: write
2021
# Service containers to run with `container-job`
2122
services:
2223
# Label used to access the service container
@@ -56,26 +57,18 @@ jobs:
5657
env:
5758
ORG_GRADLE_PROJECT_githubUser: x-access-token
5859
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
59-
- name: Login to GitHub Packages Docker Registry
60-
uses: docker/login-action@v3
60+
61+
- name: Push docker image to GAR
62+
uses: nais/docker-build-push@v0
63+
id: docker-build-push
6164
with:
62-
registry: ghcr.io
63-
username: ${{ github.actor }}
64-
password: ${{ secrets.GITHUB_TOKEN }}
65-
- name: Build and publish Docker image
66-
run: |
67-
docker build --tag ${IMAGE} .
68-
docker push ${IMAGE}
65+
team: helsearbeidsgiver
66+
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
67+
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
6968

70-
deploy:
71-
name: Deploy to DEV
72-
needs: build
73-
runs-on: ubuntu-latest
74-
permissions:
75-
id-token: write
76-
steps:
77-
- uses: actions/checkout@v4
78-
- uses: nais/deploy/actions/deploy@v2
69+
- name: Deploy to DEV
70+
uses: nais/deploy/actions/deploy@v2
7971
env:
8072
CLUSTER: dev-gcp
8173
RESOURCE: deploy/dev.yml
74+
VAR: image=${{ steps.docker-build-push.outputs.image }}

.github/workflows/prod.yml

+12-20
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ env:
99

1010
jobs:
1111
# Label of the container job
12-
build:
12+
build_and_deploy_to_prod:
1313
# You must use a Linux environment when using service containers or container jobs
1414
runs-on: ubuntu-latest
1515
permissions:
16-
packages: write
16+
contents: read
17+
id-token: write
1718
# Service containers to run with `container-job`
1819
services:
1920
# Label used to access the service container
@@ -53,26 +54,17 @@ jobs:
5354
env:
5455
ORG_GRADLE_PROJECT_githubUser: x-access-token
5556
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
56-
- name: Login to GitHub Packages Docker Registry
57-
uses: docker/login-action@v3
57+
- name: Push docker image to GAR
58+
uses: nais/docker-build-push@v0
59+
id: docker-build-push
5860
with:
59-
registry: ghcr.io
60-
username: ${{ github.actor }}
61-
password: ${{ secrets.GITHUB_TOKEN }}
62-
- name: Build and publish Docker image
63-
run: |
64-
docker build --tag ${IMAGE} .
65-
docker push ${IMAGE}
61+
team: helsearbeidsgiver
62+
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
63+
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
6664

67-
deploy:
68-
name: Deploy to PROD-GCP
69-
needs: build
70-
runs-on: ubuntu-latest
71-
permissions:
72-
id-token: write
73-
steps:
74-
- uses: actions/checkout@v4
75-
- uses: nais/deploy/actions/deploy@v2
65+
- name: Deploy to PROD-GCP
66+
uses: nais/deploy/actions/deploy@v2
7667
env:
7768
CLUSTER: prod-gcp
7869
RESOURCE: deploy/prod.yml
70+
VAR: image=${{ steps.docker-build-push.outputs.image }}

Dockerfile

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
FROM ghcr.io/navikt/baseimages/temurin:21
1+
FROM gcr.io/distroless/java21
22
COPY build/libs/*.jar ./
3-
4-
ENV JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom \
5-
-Dspring.profiles.active=remote"
3+
ENV JAVA_OPTS='-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'
4+
ENV LANG='nb_NO.UTF-8' LANGUAGE='nb_NO:nb' LC_ALL='nb:NO.UTF-8' TZ="Europe/Oslo"
5+
ENTRYPOINT ["java", "-jar", "/app.jar"]
6+
EXPOSE 8080

0 commit comments

Comments
 (0)