Skip to content

Commit

Permalink
Merge branch 'master' into kort-søknad_bruker-kan-legge-kategorier-på…
Browse files Browse the repository at this point in the history
…-dokumenter-som-opplastes-under-Annet

# Conflicts:
#	src/app.tsx
  • Loading branch information
joeldlin committed Nov 29, 2024
2 parents 11806d9 + aaa894b commit a2c007d
Show file tree
Hide file tree
Showing 24 changed files with 210 additions and 280 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
scripts/
node_modules/
src/generated
build/
Dockerfile
3 changes: 2 additions & 1 deletion .github/actions/build-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ outputs:
runs:
using: 'composite'
steps:
- uses: actions/checkout@v4

- name: 'Create artifact version'
id: artifact-version
uses: navikt/sosialhjelp-ci/actions/create-artifact-version@main
Expand All @@ -34,7 +36,6 @@ runs:
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: "${{ env.DOCKER_IMAGE }}:latest,${{ env.DOCKER_IMAGE }}:${{ steps.final-tag.outputs.tag }}"
secrets: "NODE_AUTH_TOKEN=${{ env.READER_TOKEN }}"
Expand Down
7 changes: 6 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ updates:
schedule:
interval: daily
commit-message:
prefix: "[docker]"
prefix: "[docker]"
# We had stability issues with Next 14 and Node 22.
# When we do make the jump, please remove this kommentar.
ignore:
- dependency-name: "node"
versions: [ ">=22.0.0" ]
1 change: 1 addition & 0 deletions .github/workflows/build_deploy_gcp_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
name: "Build and deploy to dev-gcp"

on:
workflow_dispatch:
push:
branches:
- "dev"
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/build_deploy_gcp_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,14 @@ jobs:
image_suffix: ${{ matrix.environment }}
build_args: |
DIGISOS_ENV=${{ matrix.environment }}
LOGIN_SESSION_API_URL=https://www.nav.no/sosialhjelp/soknad/oauth2/session
LOGOUT_URL=https://www.nav.no/sosialhjelp/soknad/oauth2/logout
NAIS_MANAGEMENT_PROJECT_ID=${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
LOGIN_SESSION_API_URL="https://www.nav.no/sosialhjelp/soknad/oauth2/session"
LOGOUT_URL="https://www.nav.no/sosialhjelp/soknad/oauth2/logout"
build_secrets: |
NAIS_WORKLOAD_IDENTITY_PROVIDER=${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
NODE_AUTH_TOKEN=${{ secrets.READER_TOKEN }}
- name: "Deploy to ${{ matrix.environment }}"
uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
RESOURCE: .nais/app.yaml
CLUSTER: ${{ matrix.cluster }}
REF: ${{ github.sha }}
Expand Down
37 changes: 13 additions & 24 deletions .github/workflows/build_deploy_mock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,43 @@ env:
NEXT_PUBLIC_DIGISOS_ENV: mock

jobs:
build-deploy:
name: "Build image and deploy"
build-image:
name: "Build Artifact and Image"
runs-on: ubuntu-latest
outputs:
docker-tag: ${{ steps.docker-image.outputs.full-tag }}
artifact-version: ${{ steps.docker-image.outputs.artifact-version }}
permissions:
contents: write
packages: write
actions: write
id-token: write
env:
READER_TOKEN: ${{ secrets.READER_TOKEN }}
WORKFLOW_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: 'Build npm project'
uses: navikt/sosialhjelp-ci/actions/build-npm@main
with:
node-version: 22
build-less: 'false'
reader-token: ${{ secrets.READER_TOKEN }}
run-test: 'false'
run-orval: 'true'

- name: "Build Docker Image"
id: docker-image
uses: navikt/sosialhjelp-soknad/.github/actions/build-image@master
with:
prefix: ${{ env.NEXT_PUBLIC_DIGISOS_ENV }}

- name: 'Upload static files to cdn'
id: upload
uses: nais/deploy/actions/cdn-upload/v2@master
with:
team: teamdigisos
source: ./build/static
destination: "/sosialhjelp-soknad/_next"
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
deploy-app:
name: "Deploy Application"
runs-on: ubuntu-latest
needs: build-image
permissions:
packages: write
contents: write
steps:
- uses: actions/checkout@v4

- id: docker-image-tag
run: |
echo "IMAGE_TAG=${{ env.DOCKER_IMAGE }}:${{ steps.docker-image.outputs.full-tag }}" >> $GITHUB_ENV
echo "IMAGE_TAG=${{ env.DOCKER_IMAGE }}:${{ needs.build-image.outputs.docker-tag }}" >> $GITHUB_ENV
- name: Deploy til ${{ env.NEXT_PUBLIC_DIGISOS_ENV }}
uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
RESOURCE: .nais/app.yaml
VARS: .nais/vars/mock.yaml
CLUSTER: dev-gcp
Expand Down
57 changes: 18 additions & 39 deletions .github/workflows/build_dev_image.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,22 @@
name: "Build dev-sbs Image"
on:
workflow_dispatch:
workflow_dispatch:

jobs:
build-image:
name: "Build dev-sbs Image"
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
actions: write
id-token: write
env:
NEXT_PUBLIC_DIGISOS_ENV: dev-sbs
DOCKER_IMAGE: ghcr.io/${{ github.repository }}/${{ github.event.repository.name }}
READER_TOKEN: ${{ secrets.READER_TOKEN }}
WORKFLOW_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: 'Build npm project'
uses: navikt/sosialhjelp-ci/actions/build-npm@main
with:
node-version: 22
build-less: 'false'
reader-token: ${{ secrets.READER_TOKEN }}
run-test: 'false'
run-orval: 'true'

- name: 'Upload static files to cdn'
id: upload
uses: nais/deploy/actions/cdn-upload/v2@master
with:
team: teamdigisos
source: ./build/static
destination: "/sosialhjelp-soknad/_next"
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}

- name: "Build Docker Image"
uses: navikt/sosialhjelp-soknad/.github/actions/build-image@master
with:
prefix: ${{ env.NEXT_PUBLIC_DIGISOS_ENV }}
build-image:
name: "Build dev-sbs Image"
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
actions: write
env:
NEXT_PUBLIC_DIGISOS_ENV: dev-sbs
DOCKER_IMAGE: ghcr.io/${{ github.repository }}/${{ github.event.repository.name }}
READER_TOKEN: ${{ secrets.READER_TOKEN }}
WORKFLOW_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: "Build Docker Image"
uses: navikt/sosialhjelp-soknad/.github/actions/build-image@master
with:
prefix: ${{ env.NEXT_PUBLIC_DIGISOS_ENV }}
67 changes: 24 additions & 43 deletions .github/workflows/build_prod_image.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,28 @@
name: Build prod-sbs image - HUSK MANUELL DEPLOY TIL PROD!
on:
workflow_run:
workflows: [ "Build code and run test" ]
branches:
- master
- 'pre-next'
types:
- completed
workflow_run:
workflows: ["Build code and run test"]
branches:
- master
- 'pre-next'
types:
- completed

jobs:
build-image:
name: "Build prod-sbs Image"
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
actions: write
id-token: write
env:
NEXT_PUBLIC_DIGISOS_ENV: prod-sbs
DOCKER_IMAGE: ghcr.io/${{ github.repository }}/${{ github.event.repository.name }}
READER_TOKEN: ${{ secrets.READER_TOKEN }}
WORKFLOW_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: 'Build npm project'
uses: navikt/sosialhjelp-ci/actions/build-npm@main
with:
node-version: 22
build-less: 'false'
reader-token: ${{ secrets.READER_TOKEN }}
run-test: 'false'
run-orval: 'true'
- name: 'Upload static files to cdn'
id: upload
uses: nais/deploy/actions/cdn-upload/v2@master
with:
team: teamdigisos
source: ./build/static
destination: "/sosialhjelp-soknad/_next"
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
- name: "Build Docker Image"
uses: navikt/sosialhjelp-soknad/.github/actions/build-image@master
with:
prefix: ${{ env.NEXT_PUBLIC_DIGISOS_ENV }}
build-image:
name: "Build prod-sbs Image"
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
actions: write
env:
NEXT_PUBLIC_DIGISOS_ENV: prod-sbs
DOCKER_IMAGE: ghcr.io/${{ github.repository }}/${{ github.event.repository.name }}
READER_TOKEN: ${{ secrets.READER_TOKEN }}
WORKFLOW_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: "Build Docker Image"
uses: navikt/sosialhjelp-soknad/.github/actions/build-image@master
with:
prefix: ${{ env.NEXT_PUBLIC_DIGISOS_ENV }}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22
20
28 changes: 5 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
# - .github/dependabot.yml (fjern versjonspin for docker)
# - packages.json under "engines" (her leter dependabot npm)
# - .ncurc.js (automatiske oppdateringer for node-types)
FROM node:22-alpine AS dependencies
# pt er vi på node 18 fordi ellers plager dekoratoren oss med "body has already been consumed"
FROM node:18-alpine AS dependencies

WORKDIR /app
COPY package.json .
COPY package-lock.json .
COPY .npmrc.dockerbuild .npmrc

RUN --mount=type=secret,id=NODE_AUTH_TOKEN,env=NODE_AUTH_TOKEN \
RUN --mount=type=secret,id=NODE_AUTH_TOKEN NODE_AUTH_TOKEN=$(cat /run/secrets/NODE_AUTH_TOKEN) \
npm ci --prefer-offline --no-audit

FROM node:22-alpine AS builder
FROM node:18-alpine AS builder

ARG DIGISOS_ENV
ARG LOGIN_SESSION_API_URL
Expand All @@ -30,24 +31,8 @@ RUN npm run orval
RUN npm run build
RUN npm prune --production

# Upload static assets to GCS
FROM google/cloud-sdk:latest AS uploader

ARG NAIS_MANAGEMENT_PROJECT_ID
ENV NAIS_MANAGEMENT_PROJECT_ID=${NAIS_MANAGEMENT_PROJECT_ID}

# Copy the upload script into the container
WORKDIR /app
COPY uploadStaticToCdn.sh /app/uploadStaticToCdn.sh
COPY --from=builder /app/build/static static

# Make the script executable
RUN chmod +x /app/uploadStaticToCdn.sh

RUN --mount=type=secret,id=NAIS_WORKLOAD_IDENTITY_PROVIDER,env=NAIS_WORKLOAD_IDENTITY_PROVIDER \
/app/uploadStaticToCdn.sh

FROM gcr.io/distroless/nodejs22-debian12 AS runner
FROM gcr.io/distroless/nodejs18-debian12 AS runner

ARG DIGISOS_ENV

Expand All @@ -58,9 +43,6 @@ ENV NODE_ENV=production

WORKDIR /app

# for å forhindre uploader-steget fra å bli optimalisert vekk, lager
# vi en falsk avhengighet
COPY --from=uploader /app/static /dev/null
COPY --from=builder --chown=1069:1069 /app/build build
COPY --from=builder /app/node_modules/ node_modules/
COPY package.json .
Expand Down
14 changes: 14 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import nextPlugin from "@next/eslint-plugin-next";
import globals from "globals";

export default tseslint.config(
// server.mjs er Node-serveren vår, så andre regler gjelder for den.
{
files: ["server.mjs"],
languageOptions: {
globals: {
...globals.node,
},
},
},
{ignores: ["build/**/*", "src/generated/**/*"]},
eslint.configs.recommended,
...tseslint.configs.recommended,
Expand All @@ -15,6 +25,10 @@ export default tseslint.config(
rules: {
...nextPlugin.configs.recommended.rules,
...nextPlugin.configs["core-web-vitals"].rules,
},
},
{
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": ["error", {argsIgnorePattern: "^_"}],
"@next/next/no-img-element": "off",
Expand Down
6 changes: 1 addition & 5 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ import createNextIntlPlugin from "next-intl/plugin";
const withNextIntl = createNextIntlPlugin();
/** @type {import('next').NextConfig} */
const nextConfig = {
distDir: "./build",
distDir: "./build", // Changes the build output directory to `./build/`.
// FIXME: Use environment variables
basePath: "/sosialhjelp/soknad",
// For å unngå issues med nginx
trailingSlash: false,
output: "standalone",
assetPrefix: process.env.NAIS_IDENTITY_PROVIDER?.length
? "https://cdn.nav.no/teamdigisos/sosialhjelp-soknad"
: undefined,
experimental: {
optimizePackageImports: ["@navikt/ds-react", "@navikt/aksel-icons"],
},
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a2c007d

Please sign in to comment.