From dac491841c967a8be2268ce3955775413c4b716c Mon Sep 17 00:00:00 2001 From: Tor Idland Date: Tue, 27 Feb 2024 14:17:31 +0100 Subject: [PATCH] =?UTF-8?q?:construction=5Fworker:=20Fjerner=20labs=20fra?= =?UTF-8?q?=20github=20actions=20og=20st=C3=B8tter=20yarn=20berry=20i=20al?= =?UTF-8?q?le=20actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{dev.yaml => build-and-deploy.yaml} | 2 - .../workflows/build-dev-mock-historisk.yaml | 61 ++++++++++++ .github/workflows/build-dev-mock.yaml | 57 +++++++++++ .github/workflows/build-labs-historisk.yaml | 64 ------------- .github/workflows/build-labs-mock.yaml | 96 ------------------- ...sk.yaml => dev-mock-delete-historisk.yaml} | 6 +- .nais/{labs.env => dev-mock.env} | 2 +- .nais/{labs-gcp.yaml => dev-mock.yaml} | 6 +- .nais/frozen-labs.yaml | 23 ----- ...risk-labs.yaml => historisk-dev-mock.yaml} | 0 DockerfileLabs | 19 ---- 11 files changed, 125 insertions(+), 211 deletions(-) rename .github/workflows/{dev.yaml => build-and-deploy.yaml} (93%) create mode 100644 .github/workflows/build-dev-mock-historisk.yaml create mode 100644 .github/workflows/build-dev-mock.yaml delete mode 100644 .github/workflows/build-labs-historisk.yaml delete mode 100644 .github/workflows/build-labs-mock.yaml rename .github/workflows/{labs-delete-historisk.yaml => dev-mock-delete-historisk.yaml} (82%) rename .nais/{labs.env => dev-mock.env} (89%) rename .nais/{labs-gcp.yaml => dev-mock.yaml} (86%) delete mode 100644 .nais/frozen-labs.yaml rename .nais/{historisk-labs.yaml => historisk-dev-mock.yaml} (100%) delete mode 100644 DockerfileLabs diff --git a/.github/workflows/dev.yaml b/.github/workflows/build-and-deploy.yaml similarity index 93% rename from .github/workflows/dev.yaml rename to .github/workflows/build-and-deploy.yaml index 19fd6571..257f676e 100644 --- a/.github/workflows/dev.yaml +++ b/.github/workflows/build-and-deploy.yaml @@ -6,8 +6,6 @@ on: - main paths-ignore: - '**.md' -env: - IMAGE_BASE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/aap/${{ github.event.repository.name }} jobs: buildDev: uses: navikt/aap-workflows/.github/workflows/frontend-next-build.yml@frontend-next-build-yarnberry diff --git a/.github/workflows/build-dev-mock-historisk.yaml b/.github/workflows/build-dev-mock-historisk.yaml new file mode 100644 index 00000000..d952f7b7 --- /dev/null +++ b/.github/workflows/build-dev-mock-historisk.yaml @@ -0,0 +1,61 @@ +name: "Labs: historisk snapshot" +on: + workflow_dispatch: + push: + branches: + - "labs-historisk-**" +env: + "IMAGE": "ghcr.io/${{ github.repository }}-labs-historisk:${{ github.sha }}" +jobs: + buildMock: + name: build + runs-on: ubuntu-latest + env: + NPM_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} + SKIP_YARN_COREPACK_CHECK: true + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://npm.pkg.github.com + cache: yarn + - name: Enable Corepack + run: corepack enable + - name: Cache client node_modules + id: cache-node-modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - name: install dependencies Yarn + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: yarn install --immutable + - name: Copy env-file # TODO: Se om vi kan finne en bedre løsning her på sikt + run: cp .nais/dev-mock.env .env + - name: run build + run: yarn run build + - uses: nais/docker-build-push@v0 + with: + team: aap + identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} + project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} + image_suffix: -dev-gcp-mock-historisk + tag: ${{ github.sha }} + "deployAppToLabsHistorisk": + name: "Deploy branch to dev" + needs: "buildMock" + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v3" + - uses: gacts/github-slug@v1 + id: slug + with: + to-slug: aap-soknad-${{ github.ref_name }} + - name: "Deploy historisk søknad til dev" + uses: "nais/deploy/actions/deploy@v1" + env: + "APIKEY": "${{ secrets.NAIS_DEPLOY_APIKEY }}" + "CLUSTER": "dev-gcp" + "RESOURCE": ".nais/historisk-dev-mock.yaml" + "VAR": image=${{ env.IMAGE }},ingress=https://${{ steps.slug.outputs.slug }}.ekstern.dev.nav.no,appname=${{ steps.slug.outputs.slug }},replicas=1,branchState=alive diff --git a/.github/workflows/build-dev-mock.yaml b/.github/workflows/build-dev-mock.yaml new file mode 100644 index 00000000..b54e180c --- /dev/null +++ b/.github/workflows/build-dev-mock.yaml @@ -0,0 +1,57 @@ +name: Build and deploy mocket versjon av aap-soknad +on: + workflow_dispatch: + push: + branches: + - main + paths-ignore: + - '**.md' +env: + IMAGE_SUFFIX: dev-gcp-mock +jobs: + buildMock: + name: build + runs-on: ubuntu-latest + env: + NPM_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} + SKIP_YARN_COREPACK_CHECK: true + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://npm.pkg.github.com + cache: yarn + - name: Enable Corepack + run: corepack enable + - name: Cache client node_modules + id: cache-node-modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - name: install dependencies Yarn + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: yarn install --immutable + - name: Copy env-file # TODO: Se om vi kan finne en bedre løsning her på sikt + run: cp .nais/dev-mock.env .env + - name: run build + run: yarn run build + - uses: nais/docker-build-push@v0 + with: + team: aap + identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} + project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} + image_suffix: -dev-gcp-mock + tag: ${{ github.sha }} + deployMock: + needs: buildMock + uses: navikt/aap-workflows/.github/workflows/deploy.yml@main + permissions: + contents: read + id-token: write + secrets: inherit + with: + cluster: dev-gcp + manifest: .nais/dev-mock.yaml + imageSuffix: -dev-gcp-mock diff --git a/.github/workflows/build-labs-historisk.yaml b/.github/workflows/build-labs-historisk.yaml deleted file mode 100644 index 0d16c779..00000000 --- a/.github/workflows/build-labs-historisk.yaml +++ /dev/null @@ -1,64 +0,0 @@ -name: "Labs: historisk snapshot" -on: - workflow_dispatch: - push: - branches: - - "labs-historisk-**" -env: - "IMAGE": "ghcr.io/${{ github.repository }}-labs-historisk:${{ github.sha }}" -jobs: - "build": - name: "build" - runs-on: "ubuntu-latest" - steps: - - uses: "actions/checkout@v3" - - uses: "actions/setup-node@v3" - with: - node-version: "20" - registry-url: "https://npm.pkg.github.com" - cache: "yarn" - - name: "install dependencies Yarn" - run: "yarn install --frozen-lockfile" - env: - NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} - - name: Copy env-file for labs - run: cp .nais/labs.env .env.local - - name: "client tests" - run: "yarn test" - - name: "Bygg klient(yarn run build)" - run: "yarn run build" - - name: "Set up Docker Buildx" - id: "buildx" - uses: "docker/setup-buildx-action@v1" - - name: "Login to GitHub Docker Registry" - uses: "docker/login-action@v1" - with: - "registry": "ghcr.io" - "username": "${{ github.actor }}" - "password": "${{ secrets.GITHUB_TOKEN }}" - - name: "Build and push Docker" - uses: "docker/build-push-action@v2" - with: - context: . - file: DockerfileLabs - tags: "${{ env.IMAGE }}" - push: "true" - cache-from: "type=gha" - cache-to: "type=gha,mode=max" - "deployAppToLabsHistorisk": - name: "Deploy branch to labs" - needs: "build" - runs-on: "ubuntu-latest" - steps: - - uses: "actions/checkout@v3" - - uses: gacts/github-slug@v1 - id: slug - with: - to-slug: aap-soknad-${{ github.ref_name }} - - name: "Deploy to LABS" - uses: "nais/deploy/actions/deploy@v1" - env: - "APIKEY": "${{ secrets.NAIS_DEPLOY_APIKEY }}" - "CLUSTER": "dev-gcp" - "RESOURCE": ".nais/historisk-labs.yaml" - "VAR": image=${{ env.IMAGE }},ingress=https://${{ steps.slug.outputs.slug }}.ekstern.dev.nav.no,appname=${{ steps.slug.outputs.slug }},replicas=1,branchState=alive diff --git a/.github/workflows/build-labs-mock.yaml b/.github/workflows/build-labs-mock.yaml deleted file mode 100644 index 2d6e0ecc..00000000 --- a/.github/workflows/build-labs-mock.yaml +++ /dev/null @@ -1,96 +0,0 @@ -name: Build and deploy aap-soknad to labs -on: - workflow_dispatch: - push: - branches: - - main - paths-ignore: - - '**.md' -env: - IMAGE_BASE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/aap/${{ github.event.repository.name }} -jobs: - build: - name: build - runs-on: ubuntu-latest - outputs: - image: ${{ steps.image.outputs.image }} - 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: yarn - - - name: Cache client node_modules - id: cache-node-modules - uses: actions/cache@v3 - with: - path: node_modules - key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} - - - name: install dependencies Yarn - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: yarn install --frozen-lockfile - env: - NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} - - - name: Copy env-file for labs - run: cp .nais/labs.env .env.local - - - name: client tests - run: yarn test - - - name: Bygg klient(yarn run build) - run: yarn run build - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Setter tag-navn - run: echo "TAG=$(date +%Y.%m.%d.%H%M%S)-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV - - - name: Setter image-navn - id: image - run: | - echo "IMAGE=$(echo $IMAGE_BASE)-$(echo $TAG)" >> $GITHUB_ENV - echo "image=$(echo $IMAGE_BASE)-$(echo $TAG)" >> $GITHUB_OUTPUT - - - name: Login GAR - uses: nais/login@v0 - with: - project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} - identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} - team: aap - - - name: Build and push Docker - uses: docker/build-push-action@v2 - with: - context: . - file: DockerfileLabs - tags: ${{ env.IMAGE }} - push: true - cache-from: type=gha - cache-to: type=gha,mode=max - - deployAppToLabs: - name: Deploy app to labs - needs: build - runs-on: ubuntu-latest - steps: - - - uses: actions/checkout@v3 - - - name: Deploy to LABS - uses: nais/deploy/actions/deploy@v1 - env: - IMAGE: ${{needs.build.outputs.image}} - APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} - CLUSTER: dev-gcp - RESOURCE: .nais/labs-gcp.yaml diff --git a/.github/workflows/labs-delete-historisk.yaml b/.github/workflows/dev-mock-delete-historisk.yaml similarity index 82% rename from .github/workflows/labs-delete-historisk.yaml rename to .github/workflows/dev-mock-delete-historisk.yaml index 27734fb1..23445f8f 100644 --- a/.github/workflows/labs-delete-historisk.yaml +++ b/.github/workflows/dev-mock-delete-historisk.yaml @@ -9,11 +9,11 @@ jobs: name: Delete branch labs-gcp runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Scale down labs-gcp + - uses: actions/checkout@v4 + - name: Scale down dev-gcp-mock-historisk uses: nais/deploy/actions/deploy@v1 env: APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} CLUSTER: dev-gcp - RESOURCE: ".nais/historisk-labs.yaml" + RESOURCE: ".nais/historisk-dev-mock.yaml" VAR: image=${{ env.IMAGE }},appname=${{env.APP_NAME}},ingress=https://${{env.APP_NAME}}.ekstern.dev.nav.no,replicas=0,branchState=deleted diff --git a/.nais/labs.env b/.nais/dev-mock.env similarity index 89% rename from .nais/labs.env rename to .nais/dev-mock.env index d24741ea..acd4d46c 100644 --- a/.nais/labs.env +++ b/.nais/dev-mock.env @@ -1,4 +1,4 @@ -RUNTIME_ENVIRONMENT="labs" +RUNTIME_ENVIRONMENT="localhost" DECORATOR_ENV="dev" SOKNAD_API_URL="https://aap-soknad-api.dev.intern.nav.no" SOKNAD_API_AUDIENCE="dev-gcp:aap:soknad-api" diff --git a/.nais/labs-gcp.yaml b/.nais/dev-mock.yaml similarity index 86% rename from .nais/labs-gcp.yaml rename to .nais/dev-mock.yaml index f17c356d..fc6f1738 100644 --- a/.nais/labs-gcp.yaml +++ b/.nais/dev-mock.yaml @@ -19,9 +19,9 @@ spec: initialDelay: 20 timeout: 60 replicas: - min: 2 - max: 2 + min: 1 + max: 1 accessPolicy: outbound: external: - - host: "dekoratoren.ekstern.dev.nav.no" \ No newline at end of file + - host: "dekoratoren.ekstern.dev.nav.no" diff --git a/.nais/frozen-labs.yaml b/.nais/frozen-labs.yaml deleted file mode 100644 index 215f7b94..00000000 --- a/.nais/frozen-labs.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: "nais.io/v1alpha1" -kind: "Application" -metadata: - name: "aap-soknad-frozen" - namespace: "aap" - labels: - "team": "aap" -spec: - image: {{image}} - port: 3000 - ingresses: - - "https://aap-soknad-v1.labs.nais.io/" - liveness: - path: "/aap/soknad/api/internal/isAlive" - initialDelay: 20 - timeout: 60 - readiness: - path: "/aap/soknad/api/internal/isReady" - initialDelay: 20 - timeout: 60 - replicas: - min: 2 - max: 2 diff --git a/.nais/historisk-labs.yaml b/.nais/historisk-dev-mock.yaml similarity index 100% rename from .nais/historisk-labs.yaml rename to .nais/historisk-dev-mock.yaml diff --git a/DockerfileLabs b/DockerfileLabs deleted file mode 100644 index 082bc415..00000000 --- a/DockerfileLabs +++ /dev/null @@ -1,19 +0,0 @@ -FROM node:20-alpine - -ENV NODE_ENV production - -RUN addgroup --system --gid 1069 nodejs -RUN adduser --system --uid 1069 nextjs - -WORKDIR /app -COPY --chown=nextjs:nodejs .env.local ./ -COPY --chown=nextjs:nodejs .next/standalone ./ -COPY --chown=nextjs:nodejs .next/static ./.next/static - -USER nextjs - -EXPOSE 3000 - -ENV PORT 3000 - -CMD ["node", "server.js"]