Skip to content

Commit

Permalink
Separer configurasjon for gcp
Browse files Browse the repository at this point in the history
Egen dockerfil og build/deploy workflow
  • Loading branch information
LudvigHz committed May 14, 2024
1 parent 4686f36 commit 383f52f
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 53 deletions.
9 changes: 9 additions & 0 deletions .env.dev-gcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
VITE_MOCK_ENABLED=false
VITE_USE_HASH_ROUTER=false
VITE_HODE_URL=/internarbeidsflatedecorator
VITE_HODE_URL_V2=https://cdn.nav.no/personoversikt/internarbeidsflate-decorator-v3/dev
SKIP_PREFLIGHT_CHECK=true
VITE_AMPLITUDE_API_KEY=4b7349a378cfc18faf21e1fe6bea0cf2
VITE_AMPLITUDE_API_KEY_DEV=716ce898b7143ffd7ff3e52dfe69bae7

VITE_DRAFT_URL=modiapersonoversikt-draft.intern.dev.nav.no/modiapersonoversikt-draft
2 changes: 0 additions & 2 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ VITE_HODE_URL_V2=https://cdn.nav.no/personoversikt/internarbeidsflate-decorator-
SKIP_PREFLIGHT_CHECK=true
VITE_AMPLITUDE_API_KEY=4b7349a378cfc18faf21e1fe6bea0cf2
VITE_AMPLITUDE_API_KEY_DEV=716ce898b7143ffd7ff3e52dfe69bae7

VITE_DRAFT_URL=modiapersonoversikt-draft.intern.dev.nav.no/modiapersonoversikt-draft
56 changes: 56 additions & 0 deletions .github/workflows/gcp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build & deploy to GCP

on: [push]

env:
CI: true
TZ: Europe/Oslo

jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
id-token: write
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Test
run: npm run test
- name: Build
run: npm run build:gcp
- name: Publish Docker image
if: github.ref == 'refs/heads/dev' # || github.ref == 'refs/heads/master'
uses: nais/docker-build-push@v0
id: docker-build-push
with:
dockerfile: Dockerfile.gcp
team: personoversikt
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}

deploy-dev:
name: Deploy to dev-gcp
needs: build
if: github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v2
env:
PRINT_PAYLOAD: true
CLUSTER: dev-gcp
RESOURCE: .nais/dev.yaml
VAR: version=${{ github.sha }},image=${{ needs.build.outputs.image }}
21 changes: 1 addition & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ name: Build, push, and deploy
on: [push]

env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
CI: true
TZ: Europe/Oslo
Q2_TEST_BRANCH: refs/heads/gcp

jobs:
build:
Expand All @@ -31,7 +29,7 @@ jobs:
- name: Build
run: npm run build
- name: Publish Docker image
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master' || github.ref == env.Q2_TEST_BRANCH
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master'
uses: nais/docker-build-push@v0
id: docker-build-push
with:
Expand Down Expand Up @@ -59,23 +57,6 @@ jobs:
RESOURCE: .nais/qa-template.yaml
VAR: q_env=${{ matrix.q_env }},version=${{ github.sha }},image=${{ needs.build.outputs.image }}

deploy-dev:
name: Deploy to dev-gcp
needs: build
if: github.ref == 'refs/heads/gcp'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v2
env:
PRINT_PAYLOAD: true
CLUSTER: dev-gcp
RESOURCE: .nais/dev.yaml
VAR: version=${{ github.sha }},image=${{ needs.build.outputs.image }}

deploy-prod:
name: Deploy to prod
needs: build
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM europe-north1-docker.pkg.dev/nais-management-233d/personoversikt/modia-frontend:0.10-node
ADD proxy-config-q2.json proxy-config.json
COPY build ./static
ENV STATIC_FILES_DIR=./static
FROM europe-north1-docker.pkg.dev/nais-management-233d/personoversikt/modialogin:2024.01.04-09.48-46cd9d7
ADD proxy-config.json /proxy-config.json
ADD preprod-proxy-config.json /preprod-proxy-config.json
COPY build /www
6 changes: 6 additions & 0 deletions Dockerfile.gcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM europe-north1-docker.pkg.dev/nais-management-233d/personoversikt/modia-frontend:0.10-node
ADD proxy-config-q2.json proxy-config.json
COPY build ./static

ENV STATIC_FILES_DIR=./static
ENV BASE_PATH=/
27 changes: 0 additions & 27 deletions Dockerfile_heroku

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"scripts": {
"start": "vite",
"build": "vite build",
"build:gcp": "vite build --base=/",
"upload-sourcemaps": "cross-env GIT_COMMIT_HASH=$(git rev-parse HEAD) node _scripts/upload-sourcemaps.js",
"test": "vitest",
"lint": "eslint --ext js,jsx,ts,tsx src",
Expand Down

0 comments on commit 383f52f

Please sign in to comment.