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/.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: "/" 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; + } +}