From da8e761b3ac7cb3d9b691db46901255b93e17037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Birm=C3=A9?= Date: Tue, 26 Mar 2024 13:17:49 +0100 Subject: [PATCH 1/2] chore: workflow to deploy to demo site --- .github/workflows/dispath.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/dispath.yml diff --git a/.github/workflows/dispath.yml b/.github/workflows/dispath.yml new file mode 100644 index 00000000..e526554d --- /dev/null +++ b/.github/workflows/dispath.yml @@ -0,0 +1,33 @@ +name: Manually trigger deploy to demo site +on: workflow_dispatch + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + registry-url: https://registry.npmjs.org/ + + - name: Build + run: | + yarn + yarn build + + - name: Sync to Demo bucket + uses: jakejarvis/s3-sync-action@v0.5.1 + with: + args: --follow-symlinks --delete + env: + AWS_S3_BUCKET: "origin-intercom-app" + AWS_ACCESS_KEY_ID: ${{ secrets.S3_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_AWS_SECRET_ACCESS_KEY }} + AWS_REGION: "eu-north-1" + SOURCE_DIR: "dist/" + DEST_DIR: "/" From f6902195d99c22ec93e777d688e18e0b19c2a53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Birm=C3=A9?= Date: Tue, 26 Mar 2024 13:21:46 +0100 Subject: [PATCH 2/2] chore: base for running app as container --- .dockerignore | 4 ++++ Dockerfile | 31 +++++++++++++++++++++++++++++++ nginx/nginx.conf | 8 ++++++++ 3 files changed, 43 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 nginx/nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..0ab4cb4b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +.git +**/__mocks__ +**/*.test.ts diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..5db2e931 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM node:18-alpine AS base + +# Install dependencies only when needed +FROM base AS deps +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +# RUN apk add --no-cache libc6-compat g++ cmake tar make +WORKDIR /app + +# Install dependencies based on the preferred package manager +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ +RUN yarn + +# Rebuild the source code only when needed +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +RUN yarn build + +# Production image, copy all the files and run next +FROM nginx:1.19.0 AS runner +WORKDIR /usr/share/nginx/html/app +RUN rm -rf ./* + +ENV NODE_ENV production + +COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=builder /app/dist . + +ENTRYPOINT [ "nginx", "-g", "daemon off;" ] \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 00000000..01f7f797 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,8 @@ +server { + listen 8080; + server_name frontend; + location / { + root /usr/share/nginx/html/app; + index index.html; + } +}