Skip to content
This repository was archived by the owner on Mar 30, 2022. It is now read-only.

Commit 09ebfdd

Browse files
committed
Add sites support
1 parent 00d9571 commit 09ebfdd

File tree

11 files changed

+3728
-4929
lines changed

11 files changed

+3728
-4929
lines changed

.github/workflows/build-and-deploy.yml

+59-58
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ env:
1515
BASE_IMAGE: docker.pkg.github.com/${{ github.repository }}/sykdom-i-familien
1616
GITHUB_USERNAME: x-access-token
1717
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
DATASET: multisite
19+
IMAGE: docker.pkg.github.com/${{ github.repository }}/sykdom-i-familien-preview:${{ github.sha }}
1820

1921
jobs:
2022
test:
@@ -62,50 +64,50 @@ jobs:
6264
- id: debug
6365
run: echo "${BASE_IMAGE}:${TAG}"
6466

65-
build-code-and-push-docker-dev:
66-
name: staging-build-push-docker
67-
if: github.event.action == 'publish-dev-sbs' # Build and push docker if publish staging event from sanity studio
68-
needs: set-image
69-
runs-on: ubuntu-latest
70-
env:
71-
IMAGE: ${{ needs.set-image.outputs.image }}
72-
steps:
73-
- name: Checkout code
74-
uses: actions/checkout@v1
75-
- name: Cache NPM dependencies
76-
uses: actions/cache@v1
77-
with:
78-
path: node_modules
79-
key: ${{ runner.OS }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
80-
restore-keys: |
81-
${{ runner.OS }}-npm-cache-
82-
- name: Use Node.js ${{ matrix.node-version }}
83-
uses: actions/setup-node@v1
84-
with:
85-
node-version: ${{ matrix.node-version }}
86-
87-
- name: build code
88-
env:
89-
SANITY_TOKEN: ${{ secrets.SANITY_TOKEN }}
90-
DATASET: production
91-
ENV: dev
92-
OVERLAY_DRAFTS: true
93-
WATCH_MODE: true
94-
run: |
95-
echo "Exported DATASET=$DATASET"
96-
npm i
97-
npm run build
98-
- name: Build Docker image
99-
run: |
100-
docker build -t ${IMAGE} . -f Dockerfile-dev
101-
- name: Login to Github Package Registry
102-
env:
103-
DOCKER_USERNAME: x-access-token
104-
DOCKER_PASSWORD: ${{ env.GITHUB_TOKEN }}
105-
run: |
106-
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin docker.pkg.github.com
107-
- name: Push Docker image
108-
run: 'docker push ${IMAGE}'
67+
build-code-and-push-docker-preview:
68+
name: Build code and push docker preview image
69+
if: startsWith(github.ref, 'refs/heads/preview-') || github.event.action == 'publish-dev-sbs' # Build and push docker if branch is either master or dev-*
70+
needs: test
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: Checkout code
74+
uses: actions/checkout@v1
75+
- name: Cache NPM dependencies
76+
uses: actions/cache@v1
77+
with:
78+
path: node_modules
79+
key: ${{ runner.OS }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
80+
restore-keys: |
81+
${{ runner.OS }}-npm-cache-
82+
- name: Use Node.js ${{ matrix.node-version }}
83+
uses: actions/setup-node@v1
84+
with:
85+
node-version: ${{ matrix.node-version }}
86+
- name: Use Node.js ${{ matrix.node-version }}
87+
uses: actions/setup-node@v1
88+
with:
89+
node-version: ${{ matrix.node-version }}
90+
- name: build code
91+
env:
92+
SANITY_TOKEN: ${{ secrets.SANITY_TOKEN }}
93+
DATASET: multisite
94+
ENV: dev
95+
OVERLAY_DRAFTS: true
96+
WATCH_MODE: false
97+
run: |
98+
echo "Exported DATASET=$DATASET"
99+
npm i
100+
npm run build-preview
101+
- name: Build Docker image
102+
run: |
103+
docker build -t ${IMAGE} . -f Dockerfile-dev
104+
- name: Login to Github Package Registry
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
run: |
108+
docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN}
109+
docker push ${IMAGE}
110+
109111
110112
build-code-and-push-docker-prod:
111113
name: prod-build-push-docker
@@ -155,20 +157,19 @@ jobs:
155157
- name: Push Docker image
156158
run: 'docker push ${IMAGE}'
157159

158-
deploy-dev-sbs:
159-
name: deploy-dev-sbs
160-
needs: [build-code-and-push-docker-dev, set-image] # Depends on build-code-and-push-docker job
161-
runs-on: ubuntu-latest
162-
steps:
163-
- name: Checkout code
164-
uses: actions/checkout@v1
165-
- name: deploy to dev-sbs
166-
uses: nais/deploy/actions/deploy@v1
167-
env:
168-
IMAGE: ${{ needs.set-image.outputs.image }}
169-
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
170-
CLUSTER: dev-sbs
171-
RESOURCE: nais/dev-sbs.yml
160+
deploy-dev-gcp:
161+
name: Deploy to dev-gcp
162+
if: github.event.action == 'publish-dev-sbs' || startsWith(github.ref, 'refs/heads/preview-') || startsWith(github.ref, 'refs/heads/master') # Build and push docker if branch is either master or dev-*
163+
needs: build-code-and-push-docker-preview
164+
runs-on: ubuntu-latest
165+
steps:
166+
- uses: actions/checkout@v1
167+
- uses: nais/deploy/actions/deploy@v1
168+
env:
169+
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
170+
CLUSTER: dev-gcp
171+
RESOURCE: nais/naiserator-dev.yml
172+
VARS: nais/dev-gcp.json
172173

173174
deploy-prod-sbs:
174175
name: deploy-prod-sbs

Dockerfile-dev

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ COPY . .
66

77
RUN ls -la
88

9-
CMD npm run serve
9+
CMD npm run serve-preview
1010

1111
EXPOSE ${PORT}

gatsby-node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
require('dotenv').config();
44
require('source-map-support').install();
5-
const path = require('path');
65
const svgoProps = require('./gatsbyUtils/svgoProps');
76
const SVGO = require('svgo');
87
const Sites = require('./build-utils/sites');
@@ -44,6 +43,7 @@ const createPagesForSite = async (site, onlyPublicPages, { graphql, actions }) =
4443

4544
exports.createPages = async (tools) => {
4645
const onlyPublicPages = process.env.ENV !== 'dev';
46+
console.log('onlyPublicPages:', onlyPublicPages);
4747
await createPagesForSite(Sites.sif, onlyPublicPages, tools);
4848
await createPagesForSite(Sites.arbeidsgiver, onlyPublicPages, tools);
4949
await createPagesForSite(Sites.samarbeid, onlyPublicPages, tools);

nais/dev-gcp.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"app": "sykdom-i-familien",
3+
"cluster": "dev-gcp",
4+
"namespace": "dusseldorf",
5+
"team": "dusseldorf",
6+
"minReplicas": "1",
7+
"maxReplicas": "1",
8+
"ingresses": ["https://sykdom-i-familien.dev.nav.no"],
9+
"env": {
10+
"DATASET": "multisite",
11+
"ENV": "dev",
12+
"OVERLAY_DRAFTS": true,
13+
"WATCH_MODE": false
14+
}
15+
}

nais/dev-sbs.yml

-40
This file was deleted.

nais/naiserator-dev.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: "nais.io/v1alpha1"
2+
kind: "Application"
3+
metadata:
4+
name: sykdom-i-familien
5+
namespace: dusseldorf
6+
labels:
7+
team: dusseldorf
8+
spec:
9+
image: {{ image }}
10+
port: 8080
11+
liveness:
12+
path: /isalive.txt
13+
initialDelay: 3
14+
timeout: 1
15+
periodSeconds: 5
16+
failureThreshold: 10
17+
readiness:
18+
path: /isready.txt
19+
initialDelay: 20
20+
timeout: 1
21+
resources:
22+
limits:
23+
cpu: 2000m
24+
memory: 512Mi
25+
requests:
26+
cpu: 50m
27+
memory: 128Mi
28+
accessPolicy:
29+
outbound:
30+
external:
31+
- host: www.nav.no
32+
- host: sanity.io
33+
ingresses:
34+
{{#each ingresses as |url|}}
35+
- {{url}}
36+
{{/each}}
37+
replicas:
38+
min: 1
39+
max: 1
40+
cpuThresholdPercentage: 90
41+
prometheus:
42+
enabled: true
43+
path: /metrics
44+
vault:
45+
enabled: false
46+
env:
47+
{{#each env}}
48+
- name: {{@key}}
49+
value: "{{this}}"
50+
{{/each}}

0 commit comments

Comments
 (0)