From 17a0b40b781604b40a0671e5c11b0efabd1f120a Mon Sep 17 00:00:00 2001 From: Ruslan Konviser Date: Sat, 2 Dec 2023 18:15:29 +0100 Subject: [PATCH] chore: docker file build with correct env vars --- .../workflows/docker-build-publish-dev.yml | 15 ++++++ .../workflows/docker-build-publish-prod.yml | 15 ++++++ Dockerfile | 48 ++++++++++++++++--- apps/web/.env | 2 +- 4 files changed, 73 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-build-publish-dev.yml b/.github/workflows/docker-build-publish-dev.yml index a62864c77..4bd6f6a83 100644 --- a/.github/workflows/docker-build-publish-dev.yml +++ b/.github/workflows/docker-build-publish-dev.yml @@ -36,6 +36,21 @@ jobs: cache-to: type=inline build-args: | NODE_ENV=development + NEXT_PUBLIC_GAUZY_API_SERVER_URL=${{ secrets.NEXT_PUBLIC_GAUZY_API_SERVER_URL }} + NEXT_PUBLIC_GA_MEASUREMENT_ID=${{ secrets.NEXT_PUBLIC_GA_MEASUREMENT_ID }} + NEXT_PUBLIC_CAPTCHA_SITE_KEY=${{ secrets.NEXT_PUBLIC_CAPTCHA_SITE_KEY }} + NEXT_PUBLIC_DISABLE_AUTO_REFRESH=false + NEXT_PUBLIC_COOKIE_DOMAINS=${{ secrets.NEXT_PUBLIC_COOKIE_DOMAINS }} + NEXT_PUBLIC_BOARD_APP_DOMAIN=${{ secrets.NEXT_PUBLIC_BOARD_APP_DOMAIN }} + NEXT_PUBLIC_BOARD_BACKEND_POST_URL=${{ secrets.NEXT_PUBLIC_BOARD_BACKEND_POST_URL }} + NEXT_PUBLIC_BOARD_FIREBASE_CONFIG=${{ secrets.NEXT_PUBLIC_BOARD_FIREBASE_CONFIG }} + NEXT_PUBLIC_MEET_DOMAIN=${{ secrets.NEXT_PUBLIC_MEET_DOMAIN }} + NEXT_PUBLIC_SENTRY_DSN=${{ secrets.NEXT_PUBLIC_SENTRY_DSN }} + NEXT_PUBLIC_SENTRY_DEBUG=${{ secrets.NEXT_PUBLIC_SENTRY_DEBUG }} + NEXT_PUBLIC_JITSU_BROWSER_URL=${{ secrets.NEXT_PUBLIC_JITSU_BROWSER_URL }} + NEXT_PUBLIC_JITSU_BROWSER_WRITE_KEY=${{ secrets.NEXT_PUBLIC_JITSU_BROWSER_WRITE_KEY }} + NEXT_PUBLIC_GITHUB_APP_NAME=ever-github + NEXT_PUBLIC_CHATWOOT_API_KEY=${{ secrets.NEXT_PUBLIC_CHATWOOT_API_KEY }} - name: Login to DockerHub uses: docker/login-action@v2 diff --git a/.github/workflows/docker-build-publish-prod.yml b/.github/workflows/docker-build-publish-prod.yml index 6addc3242..a47b6335b 100644 --- a/.github/workflows/docker-build-publish-prod.yml +++ b/.github/workflows/docker-build-publish-prod.yml @@ -36,6 +36,21 @@ jobs: cache-to: type=inline build-args: | NODE_ENV=production + NEXT_PUBLIC_GAUZY_API_SERVER_URL=${{ secrets.NEXT_PUBLIC_GAUZY_API_SERVER_URL }} + NEXT_PUBLIC_GA_MEASUREMENT_ID=${{ secrets.NEXT_PUBLIC_GA_MEASUREMENT_ID }} + NEXT_PUBLIC_CAPTCHA_SITE_KEY=${{ secrets.NEXT_PUBLIC_CAPTCHA_SITE_KEY }} + NEXT_PUBLIC_DISABLE_AUTO_REFRESH=false + NEXT_PUBLIC_COOKIE_DOMAINS=${{ secrets.NEXT_PUBLIC_COOKIE_DOMAINS }} + NEXT_PUBLIC_BOARD_APP_DOMAIN=${{ secrets.NEXT_PUBLIC_BOARD_APP_DOMAIN }} + NEXT_PUBLIC_BOARD_BACKEND_POST_URL=${{ secrets.NEXT_PUBLIC_BOARD_BACKEND_POST_URL }} + NEXT_PUBLIC_BOARD_FIREBASE_CONFIG=${{ secrets.NEXT_PUBLIC_BOARD_FIREBASE_CONFIG }} + NEXT_PUBLIC_MEET_DOMAIN=${{ secrets.NEXT_PUBLIC_MEET_DOMAIN }} + NEXT_PUBLIC_SENTRY_DSN=${{ secrets.NEXT_PUBLIC_SENTRY_DSN }} + NEXT_PUBLIC_SENTRY_DEBUG=${{ secrets.NEXT_PUBLIC_SENTRY_DEBUG }} + NEXT_PUBLIC_JITSU_BROWSER_URL=${{ secrets.NEXT_PUBLIC_JITSU_BROWSER_URL }} + NEXT_PUBLIC_JITSU_BROWSER_WRITE_KEY=${{ secrets.NEXT_PUBLIC_JITSU_BROWSER_WRITE_KEY }} + NEXT_PUBLIC_GITHUB_APP_NAME=ever-github + NEXT_PUBLIC_CHATWOOT_API_KEY=${{ secrets.NEXT_PUBLIC_CHATWOOT_API_KEY }} - name: Login to DockerHub uses: docker/login-action@v2 diff --git a/Dockerfile b/Dockerfile index 84f4137b9..d1a5a52b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,29 @@ # syntax = docker/dockerfile:1 -# Adjust NODE_VERSION as desired +# Ever Teams Platform + ARG NODE_VERSION=18.17.1 +ARG NEXT_PUBLIC_GAUZY_API_SERVER_URL=https://api.gauzy.co +ARG NEXT_PUBLIC_GA_MEASUREMENT_ID +ARG NEXT_PUBLIC_CAPTCHA_SITE_KEY +ARG NEXT_PUBLIC_DISABLE_AUTO_REFRESH=false +ARG NEXT_PUBLIC_COOKIE_DOMAINS=ever.team +ARG NEXT_PUBLIC_BOARD_APP_DOMAIN=https://board.ever.team +ARG NEXT_PUBLIC_BOARD_BACKEND_POST_URL=https://jsonboard.ever.team/api/v2/post/ +ARG NEXT_PUBLIC_BOARD_FIREBASE_CONFIG +ARG NEXT_PUBLIC_MEET_DOMAIN=https://meet.ever.team +ARG NEXT_PUBLIC_SENTRY_DSN +ARG NEXT_PUBLIC_SENTRY_DEBUG +ARG NEXT_PUBLIC_JITSU_BROWSER_URL +ARG NEXT_PUBLIC_JITSU_BROWSER_WRITE_KEY +ARG NEXT_PUBLIC_GITHUB_APP_NAME=ever-github +ARG NEXT_PUBLIC_CHATWOOT_API_KEY + FROM node:${NODE_VERSION}-slim as base +LABEL maintainer="ever@ever.co" +LABEL org.opencontainers.image.source https://github.com/ever-co/ever-teams + # Next.js app lives here WORKDIR /app @@ -14,17 +34,33 @@ ENV NEXT_SHARP_PATH=/temp/node_modules/sharp RUN npm i -g npm@latest # Install sharp, NextJS image optimization RUN mkdir /temp && cd /temp && \ - npm i sharp + npm i sharp RUN npm cache clean --force - # Throw-away build stage to reduce size of final image FROM base as build +# We make env vars passed as build argument to be available in this build stage because we prebuild the NextJs app +ARG NEXT_PUBLIC_GAUZY_API_SERVER_URL +ARG NEXT_PUBLIC_GA_MEASUREMENT_ID +ARG NEXT_PUBLIC_CAPTCHA_SITE_KEY +ARG NEXT_PUBLIC_DISABLE_AUTO_REFRESH +ARG NEXT_PUBLIC_COOKIE_DOMAINS +ARG NEXT_PUBLIC_BOARD_APP_DOMAIN +ARG NEXT_PUBLIC_BOARD_BACKEND_POST_URL +ARG NEXT_PUBLIC_BOARD_FIREBASE_CONFIG +ARG NEXT_PUBLIC_MEET_DOMAIN +ARG NEXT_PUBLIC_SENTRY_DSN +ARG NEXT_PUBLIC_SENTRY_DEBUG +ARG NEXT_PUBLIC_JITSU_BROWSER_URL +ARG NEXT_PUBLIC_JITSU_BROWSER_WRITE_KEY +ARG NEXT_PUBLIC_GITHUB_APP_NAME +ARG NEXT_PUBLIC_CHATWOOT_API_KEY + # Install packages needed to build node modules RUN apt-get update -qq && \ - apt-get install -y build-essential pkg-config python-is-python3 + apt-get install -y build-essential pkg-config python-is-python3 # Install Yarn RUN npm install -g yarn --force @@ -35,7 +71,7 @@ COPY yarn.lock ./ COPY apps/web/package.json ./apps/web/package.json RUN cd apps/web && \ - yarn install --ignore-scripts + yarn install --ignore-scripts # Copy application code COPY . . @@ -47,7 +83,7 @@ RUN yarn run build:web # Remove development dependencies RUN cd apps/web && \ - yarn install --prod --ignore-scripts + yarn install --prod --ignore-scripts RUN yarn cache clean diff --git a/apps/web/.env b/apps/web/.env index 409ebce1b..539845cf2 100644 --- a/apps/web/.env +++ b/apps/web/.env @@ -34,7 +34,7 @@ APP_LOGO_URL="https://app.ever.team/assets/ever-teams.png" NEXT_PUBLIC_COOKIE_DOMAINS=ever.team # Board -NEXT_PUBLIC_BOARD_APP_DOMAIN=https://board.ever.team +NEXT_PUBLIC_BOARD_APP_DOMAIN="https://board.ever.team" NEXT_PUBLIC_BOARD_BACKEND_POST_URL="https://jsonboard.ever.team/api/v2/post/" NEXT_PUBLIC_BOARD_FIREBASE_CONFIG=