diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml new file mode 100644 index 0000000..c9d1e25 --- /dev/null +++ b/.github/workflows/build-and-deploy.yml @@ -0,0 +1,46 @@ +name: "Build and deploy app" +on: + workflow_dispatch: + push: + branches: + - "main" +env: + "IMAGE": "ghcr.io/${{ github.repository }}:${{ github.sha }}" +jobs: + "build": + name: "build" + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v3" + - uses: "actions/setup-node@v3" + with: + node-version: "18" + - name: "Install dependencies" + run: "yarn" + - name: "Build app" + run: "yarn run build" + - 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: frontend/Dockerfile + tags: "${{ env.IMAGE }}" + push: "true" + "deploy": + name: "Deploy app" + needs: "build" + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v3" + - name: "Deploy app" + uses: "nais/deploy/actions/deploy@v1" + env: + "APIKEY": "${{ secrets.NAIS_DEPLOY_APIKEY }}" + "CLUSTER": "dev-gcp" + "RESOURCE": "frontend/nais.yml" \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..499e29f --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,18 @@ +FROM node:18-alpine + +ENV NODE_ENV production + +RUN addgroup --system --gid 1069 nodejs +RUN adduser --system --uid 1069 nextjs + +WORKDIR /app +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"] \ No newline at end of file diff --git a/frontend/nais.yml b/frontend/nais.yml new file mode 100644 index 0000000..8e0558a --- /dev/null +++ b/frontend/nais.yml @@ -0,0 +1,19 @@ +apiVersion: "nais.io/v1alpha1" +kind: "Application" +metadata: + name: "helse-sprik" + namespace: "helse-sprik" +spec: + image: {{ image }} + port: 3000 + replicas: + min: 1 + max: 2 + resources: + requests: + cpu: 100m + memory: 128Mi + limits: + memory: 128Mi + ingresses: + - https://helse-sprik.intern.dev.nav.no \ No newline at end of file diff --git a/frontend/next.config.js b/frontend/next.config.js index a843cbe..248c251 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -1,6 +1,7 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, + output: 'standalone', } module.exports = nextConfig