diff --git a/.github/workflows/bygg-branch.yml b/.github/workflows/bygg-branch.yml deleted file mode 100644 index 2be4548f1..000000000 --- a/.github/workflows/bygg-branch.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Bygg branch - -on: - push: - branches: - - '*' - - '!master' - -env: - IMAGE_BASE: ghcr.io/${{ github.repository }}/min-side-arbeidsgiver - -jobs: - bygg: - name: Bygg branch - runs-on: ubuntu-latest - permissions: - contents: 'read' - id-token: 'write' - packages: 'write' - steps: - - name: Sjekk ut kode - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: actions/setup-node@v3 - with: - node-version: '18' - registry-url: https://npm.pkg.github.com/ - cache: 'npm' - - - run: npm ci - env: - NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} - - - run: npm run lint - - - run: npm run build - env: - PUBLIC_URL: https://cdn.nav.no/fager/min-side-arbeidsgiver/build/ - - - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Bygg, tag og push Docker-image - run: | - docker build --tag $IMAGE_BASE:$GITHUB_SHA . - echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_REPOSITORY --password-stdin - docker push $IMAGE_BASE:$GITHUB_SHA - - - id: upload - uses: navikt/frontend/actions/cdn-upload/v1@main - with: - cdn-team-name: fager - source: ./build/ - destination: '/min-side-arbeidsgiver' diff --git a/.github/workflows/bygg-og-deploy-master.yml b/.github/workflows/bygg-og-deploy-master.yml deleted file mode 100644 index d6db928db..000000000 --- a/.github/workflows/bygg-og-deploy-master.yml +++ /dev/null @@ -1,160 +0,0 @@ -name: Bygg og deploy master - -on: - push: - branches: - - 'master' - -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - IMAGE_BASE: ghcr.io/${{ github.repository }}/min-side-arbeidsgiver - IMAGE: ghcr.io/${{ github.repository }}/min-side-arbeidsgiver:${{ github.sha }} - -jobs: - test: - name: Test - runs-on: ubuntu-latest - steps: - - name: Sjekk ut kode - uses: actions/checkout@v2 - - - uses: actions/setup-node@v3 - with: - node-version: '16.14.2' - registry-url: https://npm.pkg.github.com/ - cache: 'npm' - - - name: Installer avhengigheter - run: npm ci --ignore-scripts --no-optional - env: - NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} - - - bygg: - name: Bygg - runs-on: ubuntu-latest - needs: test - if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' - permissions: - contents: 'read' - id-token: 'write' - packages: 'write' - steps: - - name: Sjekk ut kode - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: '18' - registry-url: https://npm.pkg.github.com/ - cache: 'npm' - - - name: Installer avhengigheter - run: npm ci --production --ignore-scripts --no-optional - env: - NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} - - - run: npm run lint - - - run: npm run build - env: - PUBLIC_URL: https://cdn.nav.no/fager/min-side-arbeidsgiver/build/ - - - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Bygg, tag og push Docker-image - run: | - docker build --tag $IMAGE --tag $IMAGE_BASE:latest . - echo $GITHUB_TOKEN | docker login docker.pkg.github.com -u $GITHUB_REPOSITORY --password-stdin - docker push $IMAGE - - - id: upload - uses: navikt/frontend/actions/cdn-upload/v1@main - with: - cdn-team-name: fager - source: ./build/ - destination: '/min-side-arbeidsgiver' - - - name: Lag sentry release - continue-on-error: true - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - run: | - npx -p @sentry/cli sentry-cli releases new "${{ github.sha }}" - npx -p @sentry/cli sentry-cli releases files "${{ github.sha }}" upload-sourcemaps build/static/js \ - --url-prefix '~/min-side-arbeidsgiver/static/js' - npx -p @sentry/cli sentry-cli releases finalize "${{ github.sha }}" - - - deploy-dev-gcp: - name: Deploy til dev-gcp - runs-on: ubuntu-latest - timeout-minutes: 3 - if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' - needs: bygg - steps: - - name: Sjekk ut kode - uses: actions/checkout@v2 - - - name: Deploy til dev-gcp - uses: nais/deploy/actions/deploy@v1 - env: - APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} - CLUSTER: dev-gcp - RESOURCE: nais/dev-gcp.yaml - PRINT_PAYLOAD: true - VAR: commit=${{ github.sha }} - - deploy-prod-gcp: - name: Deploy til prod-gcp - runs-on: ubuntu-latest - needs: bygg - steps: - - name: Sjekk ut kode - uses: actions/checkout@v2 - - name: Deploy til prod-gcp - uses: nais/deploy/actions/deploy@v1 - env: - APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} - CLUSTER: prod-gcp - RESOURCE: nais/prod-gcp.yaml - PRINT_PAYLOAD: true - VAR: commit=${{ github.sha }} - - deploy-prodlik-demo-gcp: - name: Deploy prod-lik demo - runs-on: ubuntu-latest - needs: bygg - steps: - - name: Sjekk ut kode - uses: actions/checkout@v2 - - - name: Deploy til labs-gcp - uses: nais/deploy/actions/deploy@v1 - env: - APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} - CLUSTER: dev-gcp - RESOURCE: nais/labs-gcp.yaml - PRINT_PAYLOAD: true - VAR: commit=${{ github.sha }} - - deploy-devlik-demo-gcp: - name: Deploy dev-lik demo - runs-on: ubuntu-latest - needs: bygg - steps: - - name: Sjekk ut kode - uses: actions/checkout@v2 - - - name: Deploy til labs-gcp - uses: nais/deploy/actions/deploy@v1 - env: - APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} - CLUSTER: dev-gcp - RESOURCE: nais/experimental-labs-gcp.yaml - PRINT_PAYLOAD: true - VAR: commit=${{ github.sha }} \ No newline at end of file diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 000000000..5433943d4 --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,109 @@ +name: CICD + +on: + push: + workflow_dispatch: + +jobs: + cicd: + name: CICD + runs-on: ubuntu-latest + permissions: + contents: 'read' + id-token: 'write' + packages: 'write' + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: '20' + registry-url: https://npm.pkg.github.com/ + cache: 'npm' + + - name: Installer avhengigheter (client) + run: npm ci --omit=dev --omit=optional + env: + NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} + + - name: Installer avhengigheter (server) + run: npm ci --omit=dev --omit=optional + env: + NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} + working-directory: ./server + + - run: npm run lint + + - run: npm run build + env: + PUBLIC_URL: https://cdn.nav.no/fager/min-side-arbeidsgiver/build/ + + - uses: nais/docker-build-push@v0 + id: dockerpush + with: + team: fager + tag: ${{ github.sha }} + project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} + identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} + + - id: upload + uses: navikt/frontend/actions/cdn-upload/v1@main + with: + cdn-team-name: fager + source: ./build/ + destination: '/min-side-arbeidsgiver' + + - name: Lag sentry release + continue-on-error: true + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + run: | + npx -p @sentry/cli sentry-cli releases new "${{ github.sha }}" + npx -p @sentry/cli sentry-cli releases files "${{ github.sha }}" upload-sourcemaps build/static/js \ + --url-prefix '~/min-side-arbeidsgiver/static/js' + npx -p @sentry/cli sentry-cli releases set-commits --auto "${{ github.sha }}" + npx -p @sentry/cli sentry-cli releases finalize "${{ github.sha }}" + + - name: Deploy til dev-gcp + uses: nais/deploy/actions/deploy@v1 + if: github.ref == 'refs/heads/master' + env: + APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} + IMAGE: ${{ steps.dockerpush.outputs.image }} + CLUSTER: dev-gcp + RESOURCE: nais/dev-gcp.yaml + PRINT_PAYLOAD: true + VAR: commit=${{ github.sha }} + + - name: Deploy til prod-gcp + uses: nais/deploy/actions/deploy@v1 + if: github.ref == 'refs/heads/master' + env: + APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} + IMAGE: ${{ steps.dockerpush.outputs.image }} + CLUSTER: prod-gcp + RESOURCE: nais/prod-gcp.yaml + PRINT_PAYLOAD: true + VAR: commit=${{ github.sha }} + + - name: Deploy til labs-gcp + uses: nais/deploy/actions/deploy@v1 + if: github.ref == 'refs/heads/master' + env: + APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} + IMAGE: ${{ steps.dockerpush.outputs.image }} + CLUSTER: dev-gcp + RESOURCE: nais/labs-gcp.yaml + PRINT_PAYLOAD: true + VAR: commit=${{ github.sha }} + + - name: Deploy til labs-gcp + if: github.ref == 'refs/heads/master' + uses: nais/deploy/actions/deploy@v1 + env: + APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} + IMAGE: ${{ steps.dockerpush.outputs.image }} + CLUSTER: dev-gcp + RESOURCE: nais/experimental-labs-gcp.yaml + PRINT_PAYLOAD: true + VAR: commit=${{ github.sha }} diff --git a/.github/workflows/deploy-dev-manual.yml b/.github/workflows/deploy-dev-manual.yml index a384eb3af..efeaaf5f8 100644 --- a/.github/workflows/deploy-dev-manual.yml +++ b/.github/workflows/deploy-dev-manual.yml @@ -2,44 +2,59 @@ on: workflow_dispatch name: Deploy dev og experimental labs -env: - IMAGE: ghcr.io/${{ github.repository }}/min-side-arbeidsgiver:${{github.sha}} - jobs: - deploy-dev-manual: - name: deploy dev manual - runs-on: ubuntu-latest - - steps: - - name: Sjekk ut kode - uses: actions/checkout@v2 - - - name: "Deploy dev-gcp" - uses: nais/deploy/actions/deploy@v1 - env: - APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} - CLUSTER: dev-gcp - RESOURCE: nais/dev-gcp.yaml - PRINT_PAYLOAD: true - VAR: commit=${{ github.sha }} - REF: ${{ github.sha }} - IMAGE: ${{ env.IMAGE }} - - deploy-labs-manual: - name: deploy labs manual - runs-on: ubuntu-latest - - steps: - - name: Sjekk ut kode - uses: actions/checkout@v2 - - - name: "Deploy labs-gcp" - uses: nais/deploy/actions/deploy@v1 - env: - APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} - CLUSTER: dev-gcp - RESOURCE: nais/experimental-labs-gcp.yaml - PRINT_PAYLOAD: true - VAR: commit=${{ github.sha }} - REF: ${{ github.sha }} - IMAGE: ${{ env.IMAGE }} + deploy-dev-manual: + name: deploy dev manual + runs-on: ubuntu-latest + permissions: + contents: 'read' + id-token: 'write' + + steps: + - uses: actions/checkout@v3 + + - uses: nais/login@v0 + id: login + with: + project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} + identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} + team: fager + + - name: 'Deploy dev-gcp' + uses: nais/deploy/actions/deploy@v1 + env: + APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} + CLUSTER: dev-gcp + RESOURCE: nais/dev-gcp.yaml + PRINT_PAYLOAD: true + VAR: commit=${{ github.sha }} + REF: ${{ github.sha }} + IMAGE: ${{ steps.login.outputs.registry }}/min-side-arbeidsgiver:${{ github.sha }} + + deploy-labs-manual: + name: deploy labs manual + runs-on: ubuntu-latest + permissions: + contents: 'read' + id-token: 'write' + + steps: + - uses: actions/checkout@v3 + + - uses: nais/login@v0 + id: login + with: + project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} + identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} + team: fager + + - name: 'Deploy labs-gcp' + uses: nais/deploy/actions/deploy@v1 + env: + APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} + CLUSTER: dev-gcp + RESOURCE: nais/experimental-labs-gcp.yaml + PRINT_PAYLOAD: true + VAR: commit=${{ github.sha }} + REF: ${{ github.sha }} + IMAGE: ${{ steps.login.outputs.registry }}/min-side-arbeidsgiver:${{ github.sha }} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..2a71ac0fb --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +Dockerfile +.prettierignore diff --git a/Dockerfile b/Dockerfile index 64e47f454..779ced4fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM navikt/node-express:16 +FROM gcr.io/distroless/nodejs20-debian11 WORKDIR /usr/src/app COPY build/ build/ @@ -6,9 +6,7 @@ COPY server/ server/ COPY bruker.graphql . WORKDIR /usr/src/app/server -USER root -RUN npm ci USER apprunner EXPOSE 8080 -ENTRYPOINT ["node", "server.js"] \ No newline at end of file +CMD ["server.js"] \ No newline at end of file diff --git a/Procfile b/Procfile deleted file mode 100644 index 46724afcb..000000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: node src/server/server.js \ No newline at end of file diff --git a/public/index.html b/index.html similarity index 67% rename from public/index.html rename to index.html index 7b6430903..f646c8d3c 100644 --- a/public/index.html +++ b/index.html @@ -3,8 +3,8 @@