From 46336bd0e62499633dbd0034daca2c85f356c9cc Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Thu, 17 Aug 2023 19:17:45 +0000 Subject: [PATCH 01/18] chore: Added Dockerfile for Space Project --- apps/space/Dockerfile.space | 61 +++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 apps/space/Dockerfile.space diff --git a/apps/space/Dockerfile.space b/apps/space/Dockerfile.space new file mode 100644 index 00000000000..8349bbd766c --- /dev/null +++ b/apps/space/Dockerfile.space @@ -0,0 +1,61 @@ +FROM node:18-alpine AS base + +# [Stage 1] Prune the Space Project and lockfile out the monorepo. +FROM base AS builder +RUN apk add --no-cache libc6-compat +RUN apk update + +# Installing turbo, copying monorepo and executing prune +WORKDIR /app +RUN yarn global add turbo +COPY . . + +# Space pruned as /app/out/json (deps) and /app/out/full (space) +RUN turbo prune --scope=space --docker + +# [Stage 2] Install Dependencies from deps only files from /app/out/json +FROM base AS installer +RUN apk add --no-cache libc6-compat +RUN apk update +WORKDIR /app + +# Copying package.json and lockfile from space and also from root, as /app/out/yarn-lock.json and /app/out/json +COPY --from=builder /app/out/json/ . +COPY --from=builder /app/out/yarn-lock.json ./yarn-lock.json +RUN yarn install + +# Building the Project with standalone mode ( https://nextjs.org/docs/pages/api-reference/next-config-js/output ) +COPY --from=builder ./app/out/full . +RUN yarn turbo run build --filter=space + +# [Stage: 3] Running the project +FROM base AS runner +WORKDIR /app + +# Creating user group for production, plane as usergroup and captain as user +RUN addgroup --system --gid 1001 plane +RUN adduser --system --uid 1001 captain +USER captain + +# transporting package files from installer +COPY --from=installer /app/apps/space/next.config.js . +COPY --from=installer /app/apps/space/package.json . + +# transporting builds from installer +COPY --from=installer --chown=captain:plane /app/apps/space/.next/standalone ./ +COPY --from=installer --chown=captain:plane /app/apps/space/.next ./apps/space/.next + +# Start the server +CMD node apps/space/server.js + + + + + + + + + + + + From 79845c4f0ad1dc3e6cf631aee882df9ef8ee42d5 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Fri, 18 Aug 2023 09:46:10 +0000 Subject: [PATCH 02/18] fix: next js config to standalone mode --- apps/space/next.config.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/space/next.config.js b/apps/space/next.config.js index 398eb04004b..0dd1894bbc5 100644 --- a/apps/space/next.config.js +++ b/apps/space/next.config.js @@ -1,9 +1,14 @@ /** @type {import('next').NextConfig} */ +const path = require('path') const nextConfig = { + reactStrictMode: false, + swcMinify: true, experimental: { + outputFileTracingRoot: path.join(__dirname, "../../"), appDir: true, }, + output: 'standalone' }; module.exports = nextConfig; From 94356f06ad5b9b40ec10d52be937f279a906b391 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Fri, 18 Aug 2023 09:46:54 +0000 Subject: [PATCH 03/18] fix: workedaround build error with rename 404 page --- apps/space/app/404/{page.tsx => 404.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apps/space/app/404/{page.tsx => 404.tsx} (100%) diff --git a/apps/space/app/404/page.tsx b/apps/space/app/404/404.tsx similarity index 100% rename from apps/space/app/404/page.tsx rename to apps/space/app/404/404.tsx From e61f2eda092cd6819b8419c687e2098e471fd1c0 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Fri, 18 Aug 2023 09:47:19 +0000 Subject: [PATCH 04/18] chore: modified dockerfile with new conventions --- apps/space/Dockerfile.space | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/space/Dockerfile.space b/apps/space/Dockerfile.space index 8349bbd766c..314f8f04117 100644 --- a/apps/space/Dockerfile.space +++ b/apps/space/Dockerfile.space @@ -1,6 +1,6 @@ FROM node:18-alpine AS base -# [Stage 1] Prune the Space Project and lockfile out the monorepo. +# [Stage 1] Prune the plane-deploy Project and lockfile out the monorepo. FROM base AS builder RUN apk add --no-cache libc6-compat RUN apk update @@ -10,23 +10,25 @@ WORKDIR /app RUN yarn global add turbo COPY . . -# Space pruned as /app/out/json (deps) and /app/out/full (space) -RUN turbo prune --scope=space --docker +# plane-deploy pruned as /app/out/json (deps) and /app/out/full (plane-deploy) +RUN turbo prune --scope=plane-deploy --docker # [Stage 2] Install Dependencies from deps only files from /app/out/json FROM base AS installer RUN apk add --no-cache libc6-compat +RUN apk add tree RUN apk update WORKDIR /app -# Copying package.json and lockfile from space and also from root, as /app/out/yarn-lock.json and /app/out/json +# Copying package.json and lockfile from plane-deploy and also from root, as /app/out/yarn-lock.json and /app/out/json COPY --from=builder /app/out/json/ . -COPY --from=builder /app/out/yarn-lock.json ./yarn-lock.json +COPY --from=builder /app/out/yarn.lock ./yarn.lock RUN yarn install # Building the Project with standalone mode ( https://nextjs.org/docs/pages/api-reference/next-config-js/output ) COPY --from=builder ./app/out/full . -RUN yarn turbo run build --filter=space +RUN yarn turbo run build --filter=plane-deploy +# CMD tree ./apps -I 'node_modules' # [Stage: 3] Running the project FROM base AS runner From d5ead3db672fbcee54eb9a36f74e2cb4dd5de62e Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Fri, 18 Aug 2023 10:18:25 +0000 Subject: [PATCH 05/18] chore: modified dockercompose file for new plane-deploy --- docker-compose.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index be8b9625871..696204614f0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -58,6 +58,21 @@ services: depends_on: - plane-api - plane-worker + public-deploy: + container_name: plane_public_deploy + build: + context: . + dockerfile: ./apps/space/Dockerfile.space + restart: always + command: node apps/space/server.js + env_file: + - .env + environment: + NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_DEPLOY_URL} + depends_on: + - plane-api + - plane-worker + - plane-web plane-api: container_name: planebackend From 4af6a87be41f136cfd1820b0c3f445012e065269 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Fri, 18 Aug 2023 10:22:18 +0000 Subject: [PATCH 06/18] fix: handled ts errors with possibly undefined states --- .../components/tiptap/bubble-menu/index.tsx | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/app/components/tiptap/bubble-menu/index.tsx b/apps/app/components/tiptap/bubble-menu/index.tsx index 259b5eceaa1..cab08996512 100644 --- a/apps/app/components/tiptap/bubble-menu/index.tsx +++ b/apps/app/components/tiptap/bubble-menu/index.tsx @@ -19,32 +19,32 @@ export const EditorBubbleMenu: FC = (props) => { const items: BubbleMenuItem[] = [ { name: "bold", - isActive: () => props.editor.isActive("bold"), - command: () => props.editor.chain().focus().toggleBold().run(), + isActive: () => props.editor!.isActive("bold"), + command: () => props.editor!.chain().focus().toggleBold().run(), icon: BoldIcon, }, { name: "italic", - isActive: () => props.editor.isActive("italic"), - command: () => props.editor.chain().focus().toggleItalic().run(), + isActive: () => props.editor!.isActive("italic"), + command: () => props.editor!.chain().focus().toggleItalic().run(), icon: ItalicIcon, }, { name: "underline", - isActive: () => props.editor.isActive("underline"), - command: () => props.editor.chain().focus().toggleUnderline().run(), + isActive: () => props.editor!.isActive("underline"), + command: () => props.editor!.chain().focus().toggleUnderline().run(), icon: UnderlineIcon, }, { name: "strike", - isActive: () => props.editor.isActive("strike"), - command: () => props.editor.chain().focus().toggleStrike().run(), + isActive: () => props.editor!.isActive("strike"), + command: () => props.editor!.chain().focus().toggleStrike().run(), icon: StrikethroughIcon, }, { name: "code", - isActive: () => props.editor.isActive("code"), - command: () => props.editor.chain().focus().toggleCode().run(), + isActive: () => props.editor!.isActive("code"), + command: () => props.editor!.chain().focus().toggleCode().run(), icon: CodeIcon, }, ]; @@ -78,7 +78,7 @@ export const EditorBubbleMenu: FC = (props) => { className="flex w-fit divide-x divide-custom-border-300 rounded border border-custom-border-300 bg-custom-background-100 shadow-xl" > { setIsNodeSelectorOpen(!isNodeSelectorOpen); @@ -86,7 +86,7 @@ export const EditorBubbleMenu: FC = (props) => { }} /> { setIsLinkSelectorOpen(!isLinkSelectorOpen); From e076308cbac6be86858306f9382c417f8a4f88a8 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Fri, 18 Aug 2023 13:46:25 +0000 Subject: [PATCH 07/18] chore: updated main dockerfile with plane-deploy --- Dockerfile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5cff15dc538..388c5a4ef99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,9 +5,11 @@ WORKDIR /app ENV NEXT_PUBLIC_API_BASE_URL=http://NEXT_PUBLIC_API_BASE_URL_PLACEHOLDER RUN yarn global add turbo +RUN apk add tree COPY . . -RUN turbo prune --scope=app --docker +RUN turbo prune --scope=app --scope=plane-deploy --docker +CMD tree -I node_modules/ # Add lockfile and package.json's of isolated subworkspace FROM node:18-alpine AS installer @@ -21,14 +23,14 @@ COPY --from=builder /app/out/json/ . COPY --from=builder /app/out/yarn.lock ./yarn.lock RUN yarn install -# Build the project +# # Build the project COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json COPY replace-env-vars.sh /usr/local/bin/ USER root RUN chmod +x /usr/local/bin/replace-env-vars.sh -RUN yarn turbo run build --filter=app +RUN yarn turbo run build ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \ BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL @@ -96,11 +98,16 @@ RUN adduser --system --uid 1001 captain COPY --from=installer /app/apps/app/next.config.js . COPY --from=installer /app/apps/app/package.json . +COPY --from=installer /app/apps/space/next.config.js . +COPY --from=installer /app/apps/space/package.json . COPY --from=installer --chown=captain:plane /app/apps/app/.next/standalone ./ COPY --from=installer --chown=captain:plane /app/apps/app/.next/static ./apps/app/.next/static +COPY --from=installer --chown=captain:plane /app/apps/space/.next/standalone ./ +COPY --from=installer --chown=captain:plane /app/apps/space/.next ./apps/space/.next + ENV NEXT_TELEMETRY_DISABLED 1 # RUN rm /etc/nginx/conf.d/default.conf From f7b9441e7b6175abfdc51f2bfb2cfc3da3e84fa5 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Fri, 18 Aug 2023 13:46:47 +0000 Subject: [PATCH 08/18] feat: included space project to start.sh --- start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start.sh b/start.sh index 173e333a442..2e4a7877266 100644 --- a/start.sh +++ b/start.sh @@ -6,4 +6,4 @@ set -x /usr/local/bin/replace-env-vars.sh "$BUILT_NEXT_PUBLIC_API_BASE_URL" "$NEXT_PUBLIC_API_BASE_URL" echo "Starting Plane Frontend.." -node apps/app/server.js \ No newline at end of file +node apps/app/server.js & node apps/space/server.js From b0fbe391aaced197e8ce85cbd12c9c34eb0103c9 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Fri, 18 Aug 2023 13:47:31 +0000 Subject: [PATCH 09/18] chore: modified space project port while running in production --- apps/space/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/space/package.json b/apps/space/package.json index dd7a3058c9f..e0e70246965 100644 --- a/apps/space/package.json +++ b/apps/space/package.json @@ -3,9 +3,9 @@ "version": "0.0.1", "private": true, "scripts": { - "dev": "next dev", + "dev": "next dev -p 4000", "build": "next build", - "start": "next start", + "start": "next start -p 4000", "lint": "next lint" }, "dependencies": { From 2ee451016e7e23ad88e6dede76e6f9830d2f6d6b Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Fri, 18 Aug 2023 13:48:16 +0000 Subject: [PATCH 10/18] chore: restored changes inside space project --- apps/space/app/404/{404.tsx => page.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apps/space/app/404/{404.tsx => page.tsx} (100%) diff --git a/apps/space/app/404/404.tsx b/apps/space/app/404/page.tsx similarity index 100% rename from apps/space/app/404/404.tsx rename to apps/space/app/404/page.tsx From 40df18e802ebe321f577bf6006a98aa1796b3c18 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Fri, 18 Aug 2023 13:49:14 +0000 Subject: [PATCH 11/18] chore: added ngnix config for space project running :4000 --- nginx/nginx-single-docker-image.conf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nginx/nginx-single-docker-image.conf b/nginx/nginx-single-docker-image.conf index 8d927a1b229..b9f50d664cf 100644 --- a/nginx/nginx-single-docker-image.conf +++ b/nginx/nginx-single-docker-image.conf @@ -18,6 +18,11 @@ server { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } + location /space/ { + proxy_pass http://localhost:4000/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; From 84f7186bc6013fbf914f38dc65631819baa3c9bd Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Mon, 21 Aug 2023 06:42:02 +0000 Subject: [PATCH 12/18] fix: Updated docker-compose files --- docker-compose-hub.yml | 16 ++++++++++++++++ docker-compose.yml | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docker-compose-hub.yml b/docker-compose-hub.yml index c0466e09c03..9a3af755b4a 100644 --- a/docker-compose-hub.yml +++ b/docker-compose-hub.yml @@ -54,6 +54,22 @@ services: depends_on: - plane-api - plane-worker + + public-deploy: + container_name: plane_public_deploy + build: + context: . + dockerfile: ./apps/space/Dockerfile.space + restart: always + command: node apps/space/server.js + env_file: + - .env + environment: + NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_API_BASE_URL} + depends_on: + - plane-api + - plane-worker + - plane-web plane-api: container_name: planebackend diff --git a/docker-compose.yml b/docker-compose.yml index 696204614f0..247924508aa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -68,7 +68,7 @@ services: env_file: - .env environment: - NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_DEPLOY_URL} + NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_API_BASE_URL} depends_on: - plane-api - plane-worker From 91b15f48f6cb89a39c67ec7b7cfa0ea97262890e Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Mon, 21 Aug 2023 06:43:43 +0000 Subject: [PATCH 13/18] chore: added space url for ngnix config --- nginx/nginx.conf.template | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nginx/nginx.conf.template b/nginx/nginx.conf.template index 206c94b51c3..812a47dd0bc 100644 --- a/nginx/nginx.conf.template +++ b/nginx/nginx.conf.template @@ -15,6 +15,10 @@ server { proxy_pass http://planefrontend:3000/; } + location /spaces { + proxy_pass http://planefrontend:4000/; + } + location /api/ { proxy_pass http://planebackend:8000/api/; } From 8d07d0843559c379ba76f6178d4f999ed786f9f9 Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Mon, 21 Aug 2023 07:14:10 +0000 Subject: [PATCH 14/18] chore: Updated ngnix template --- docker-compose-hub.yml | 2 +- docker-compose.yml | 2 +- nginx/nginx.conf.template | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose-hub.yml b/docker-compose-hub.yml index 9a3af755b4a..9dc1d7416bd 100644 --- a/docker-compose-hub.yml +++ b/docker-compose-hub.yml @@ -56,7 +56,7 @@ services: - plane-worker public-deploy: - container_name: plane_public_deploy + container_name: planepublicdeploy build: context: . dockerfile: ./apps/space/Dockerfile.space diff --git a/docker-compose.yml b/docker-compose.yml index 247924508aa..f48f36815a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,7 +59,7 @@ services: - plane-api - plane-worker public-deploy: - container_name: plane_public_deploy + container_name: planepublicdeploy build: context: . dockerfile: ./apps/space/Dockerfile.space diff --git a/nginx/nginx.conf.template b/nginx/nginx.conf.template index 812a47dd0bc..1da08f625fa 100644 --- a/nginx/nginx.conf.template +++ b/nginx/nginx.conf.template @@ -16,7 +16,7 @@ server { } location /spaces { - proxy_pass http://planefrontend:4000/; + proxy_pass http://planepublicdeploy:4000/; } location /api/ { From f385b762af23eb8e81a4da08201ff677e175cfde Mon Sep 17 00:00:00 2001 From: Henit Chobisa Date: Mon, 21 Aug 2023 07:29:31 +0000 Subject: [PATCH 15/18] chore: updated space url in compose hub file --- docker-compose-hub.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker-compose-hub.yml b/docker-compose-hub.yml index 9dc1d7416bd..07ea0e1d96a 100644 --- a/docker-compose-hub.yml +++ b/docker-compose-hub.yml @@ -57,9 +57,7 @@ services: public-deploy: container_name: planepublicdeploy - build: - context: . - dockerfile: ./apps/space/Dockerfile.space + image: makeplane/plane-space:latest restart: always command: node apps/space/server.js env_file: From 4ae34f37b84669087529968cbdc2b7681d5e4d3b Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Mon, 21 Aug 2023 17:11:24 +0530 Subject: [PATCH 16/18] dev: updated dockerfile.space and start and replace script --- apps/app/Dockerfile.web | 4 +- .../components/tiptap/bubble-menu/index.tsx | 22 +++--- apps/space/Dockerfile.space | 77 ++++++++++--------- apps/space/app/[workspace_slug]/page.tsx | 16 +++- apps/space/package.json | 2 +- docker-compose.yml | 12 ++- nginx/nginx.conf.template | 4 +- replace-env-vars.sh | 3 +- setup.sh | 2 +- start.sh | 4 +- 10 files changed, 84 insertions(+), 62 deletions(-) diff --git a/apps/app/Dockerfile.web b/apps/app/Dockerfile.web index e0b5f29c1e8..2b28e1fd138 100644 --- a/apps/app/Dockerfile.web +++ b/apps/app/Dockerfile.web @@ -33,8 +33,8 @@ RUN yarn turbo run build --filter=app ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \ BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL - -RUN /usr/local/bin/replace-env-vars.sh http://NEXT_PUBLIC_WEBAPP_URL_PLACEHOLDER ${NEXT_PUBLIC_API_BASE_URL} +ENV NEXT_PUBLIC_DEPLOY_URL=${NEXT_PUBLIC_DEPLOY_URL} +RUN /usr/local/bin/replace-env-vars.sh http://NEXT_PUBLIC_WEBAPP_URL_PLACEHOLDER ${NEXT_PUBLIC_API_BASE_URL} app FROM node:18-alpine AS runner WORKDIR /app diff --git a/apps/app/components/tiptap/bubble-menu/index.tsx b/apps/app/components/tiptap/bubble-menu/index.tsx index cab08996512..e689007829b 100644 --- a/apps/app/components/tiptap/bubble-menu/index.tsx +++ b/apps/app/components/tiptap/bubble-menu/index.tsx @@ -15,36 +15,36 @@ export interface BubbleMenuItem { type EditorBubbleMenuProps = Omit; -export const EditorBubbleMenu: FC = (props) => { +export const EditorBubbleMenu: FC = (props: any) => { const items: BubbleMenuItem[] = [ { name: "bold", - isActive: () => props.editor!.isActive("bold"), - command: () => props.editor!.chain().focus().toggleBold().run(), + isActive: () => props.editor?.isActive("bold"), + command: () => props.editor?.chain().focus().toggleBold().run(), icon: BoldIcon, }, { name: "italic", - isActive: () => props.editor!.isActive("italic"), - command: () => props.editor!.chain().focus().toggleItalic().run(), + isActive: () => props.editor?.isActive("italic"), + command: () => props.editor?.chain().focus().toggleItalic().run(), icon: ItalicIcon, }, { name: "underline", - isActive: () => props.editor!.isActive("underline"), - command: () => props.editor!.chain().focus().toggleUnderline().run(), + isActive: () => props.editor?.isActive("underline"), + command: () => props.editor?.chain().focus().toggleUnderline().run(), icon: UnderlineIcon, }, { name: "strike", - isActive: () => props.editor!.isActive("strike"), - command: () => props.editor!.chain().focus().toggleStrike().run(), + isActive: () => props.editor?.isActive("strike"), + command: () => props.editor?.chain().focus().toggleStrike().run(), icon: StrikethroughIcon, }, { name: "code", - isActive: () => props.editor!.isActive("code"), - command: () => props.editor!.chain().focus().toggleCode().run(), + isActive: () => props.editor?.isActive("code"), + command: () => props.editor?.chain().focus().toggleCode().run(), icon: CodeIcon, }, ]; diff --git a/apps/space/Dockerfile.space b/apps/space/Dockerfile.space index 314f8f04117..0240ddbf767 100644 --- a/apps/space/Dockerfile.space +++ b/apps/space/Dockerfile.space @@ -1,63 +1,70 @@ -FROM node:18-alpine AS base - -# [Stage 1] Prune the plane-deploy Project and lockfile out the monorepo. -FROM base AS builder -RUN apk add --no-cache libc6-compat -RUN apk update - -# Installing turbo, copying monorepo and executing prune +FROM node:18-alpine AS builder +RUN apk add --no-cache libc6-compat +# Set working directory WORKDIR /app +ENV NEXT_PUBLIC_API_BASE_URL=http://NEXT_PUBLIC_API_BASE_URL_PLACEHOLDER + RUN yarn global add turbo COPY . . -# plane-deploy pruned as /app/out/json (deps) and /app/out/full (plane-deploy) -RUN turbo prune --scope=plane-deploy --docker +RUN turbo prune --scope=space --docker + +# Add lockfile and package.json's of isolated subworkspace +FROM node:18-alpine AS installer -# [Stage 2] Install Dependencies from deps only files from /app/out/json -FROM base AS installer RUN apk add --no-cache libc6-compat -RUN apk add tree -RUN apk update WORKDIR /app +ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 -# Copying package.json and lockfile from plane-deploy and also from root, as /app/out/yarn-lock.json and /app/out/json +# First install the dependencies (as they change less often) +COPY .gitignore .gitignore COPY --from=builder /app/out/json/ . COPY --from=builder /app/out/yarn.lock ./yarn.lock -RUN yarn install +RUN yarn install --network-timeout 500000 -# Building the Project with standalone mode ( https://nextjs.org/docs/pages/api-reference/next-config-js/output ) -COPY --from=builder ./app/out/full . -RUN yarn turbo run build --filter=plane-deploy -# CMD tree ./apps -I 'node_modules' +# Build the project +COPY --from=builder /app/out/full/ . +COPY turbo.json turbo.json +COPY replace-env-vars.sh /usr/local/bin/ +USER root +RUN chmod +x /usr/local/bin/replace-env-vars.sh -# [Stage: 3] Running the project -FROM base AS runner +RUN yarn turbo run build --filter=space + +ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \ + BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL + +RUN /usr/local/bin/replace-env-vars.sh http://NEXT_PUBLIC_WEBAPP_URL_PLACEHOLDER ${NEXT_PUBLIC_API_BASE_URL} space + +FROM node:18-alpine AS runner WORKDIR /app -# Creating user group for production, plane as usergroup and captain as user +# Don't run production as root RUN addgroup --system --gid 1001 plane RUN adduser --system --uid 1001 captain USER captain -# transporting package files from installer COPY --from=installer /app/apps/space/next.config.js . COPY --from=installer /app/apps/space/package.json . -# transporting builds from installer +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing COPY --from=installer --chown=captain:plane /app/apps/space/.next/standalone ./ -COPY --from=installer --chown=captain:plane /app/apps/space/.next ./apps/space/.next - -# Start the server -CMD node apps/space/server.js - - - - - - +COPY --from=installer --chown=captain:plane /app/apps/space/.next ./apps/space/.next +ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 +ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \ + BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL +USER root +COPY replace-env-vars.sh /usr/local/bin/ +COPY start.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/replace-env-vars.sh +RUN chmod +x /usr/local/bin/start.sh +USER captain +ENV NEXT_TELEMETRY_DISABLED 1 +EXPOSE 3000 diff --git a/apps/space/app/[workspace_slug]/page.tsx b/apps/space/app/[workspace_slug]/page.tsx index c35662f5a62..715027a8904 100644 --- a/apps/space/app/[workspace_slug]/page.tsx +++ b/apps/space/app/[workspace_slug]/page.tsx @@ -1,7 +1,17 @@ "use client"; -const WorkspaceProjectPage = () => ( -
Plane Workspace Space
-); +// next imports +import { useRouter, useParams, useSearchParams } from "next/navigation"; + +const WorkspaceProjectPage = () => { + const routerParams = useParams(); + const { workspace_slug } = routerParams as { workspace_slug: string }; + + return ( +
+ Plane {workspace_slug || "nahh"} +
+ ); +}; export default WorkspaceProjectPage; diff --git a/apps/space/package.json b/apps/space/package.json index e0e70246965..e37dfa54a76 100644 --- a/apps/space/package.json +++ b/apps/space/package.json @@ -1,5 +1,5 @@ { - "name": "plane-deploy", + "name": "space", "version": "0.0.1", "private": true, "scripts": { diff --git a/docker-compose.yml b/docker-compose.yml index f48f36815a5..07aa79f3687 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -41,12 +41,14 @@ services: dockerfile: ./apps/app/Dockerfile.web args: NEXT_PUBLIC_API_BASE_URL: http://localhost:8000 + NEXT_PUBLIC_DEPLOY_URL: http://localhost/spaces restart: always - command: /usr/local/bin/start.sh + command: /usr/local/bin/start.sh apps/app/server.js app env_file: - .env environment: NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_API_BASE_URL} + NEXT_PUBLIC_DEPLOY_URL: ${NEXT_PUBLIC_DEPLOY_URL} NEXT_PUBLIC_GOOGLE_CLIENTID: "0" NEXT_PUBLIC_GITHUB_APP_NAME: "0" NEXT_PUBLIC_GITHUB_ID: "0" @@ -58,13 +60,15 @@ services: depends_on: - plane-api - plane-worker - public-deploy: - container_name: planepublicdeploy + plane-deploy: + container_name: planedeploy build: context: . dockerfile: ./apps/space/Dockerfile.space + args: + NEXT_PUBLIC_API_BASE_URL: http://localhost:8000 restart: always - command: node apps/space/server.js + command: /usr/local/bin/start.sh apps/space/server.js space env_file: - .env environment: diff --git a/nginx/nginx.conf.template b/nginx/nginx.conf.template index 1da08f625fa..796c9e10de7 100644 --- a/nginx/nginx.conf.template +++ b/nginx/nginx.conf.template @@ -15,8 +15,8 @@ server { proxy_pass http://planefrontend:3000/; } - location /spaces { - proxy_pass http://planepublicdeploy:4000/; + location /spaces/ { + proxy_pass http://planedeploy:3000/; } location /api/ { diff --git a/replace-env-vars.sh b/replace-env-vars.sh index 56c6d2025b7..afdc1492e41 100644 --- a/replace-env-vars.sh +++ b/replace-env-vars.sh @@ -1,6 +1,7 @@ #!/bin/sh FROM=$1 TO=$2 +DIRECTORY=$3 if [ "${FROM}" = "${TO}" ]; then echo "Nothing to replace, the value is already set to ${TO}." @@ -11,4 +12,4 @@ fi # Only perform action if $FROM and $TO are different. echo "Replacing all statically built instances of $FROM with this string $TO ." -grep -R -la "${FROM}" apps/app/.next | xargs -I{} sed -i "s|$FROM|$TO|g" "{}" +grep -R -la "${FROM}" apps/$DIRECTORY/.next | xargs -I{} sed -i "s|$FROM|$TO|g" "{}" diff --git a/setup.sh b/setup.sh index a5a8e9b6aed..235e1a977f7 100755 --- a/setup.sh +++ b/setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -# cp ./.env.example ./.env +cp ./.env.example ./.env # Export for tr error in mac export LC_ALL=C diff --git a/start.sh b/start.sh index 2e4a7877266..dcb97db6d3a 100644 --- a/start.sh +++ b/start.sh @@ -3,7 +3,7 @@ set -x # Replace the statically built BUILT_NEXT_PUBLIC_API_BASE_URL with run-time NEXT_PUBLIC_API_BASE_URL # NOTE: if these values are the same, this will be skipped. -/usr/local/bin/replace-env-vars.sh "$BUILT_NEXT_PUBLIC_API_BASE_URL" "$NEXT_PUBLIC_API_BASE_URL" +/usr/local/bin/replace-env-vars.sh "$BUILT_NEXT_PUBLIC_API_BASE_URL" "$NEXT_PUBLIC_API_BASE_URL" $2 echo "Starting Plane Frontend.." -node apps/app/server.js & node apps/space/server.js +node $1 From 7b1058c4fd3011112ca454b7ff094ceb86bdbbdc Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Mon, 21 Aug 2023 18:08:43 +0530 Subject: [PATCH 17/18] dev: equate hub and build docker files --- docker-compose-hub.yml | 9 +++++---- docker-compose.yml | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docker-compose-hub.yml b/docker-compose-hub.yml index 07ea0e1d96a..84ff8b833c7 100644 --- a/docker-compose-hub.yml +++ b/docker-compose-hub.yml @@ -38,11 +38,12 @@ services: container_name: planefrontend image: makeplane/plane-frontend:latest restart: always - command: /usr/local/bin/start.sh + command: /usr/local/bin/start.sh apps/app/server.js app env_file: - .env environment: NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_API_BASE_URL} + NEXT_PUBLIC_DEPLOY_URL: ${NEXT_PUBLIC_DEPLOY_URL} NEXT_PUBLIC_GOOGLE_CLIENTID: "0" NEXT_PUBLIC_GITHUB_APP_NAME: "0" NEXT_PUBLIC_GITHUB_ID: "0" @@ -55,11 +56,11 @@ services: - plane-api - plane-worker - public-deploy: - container_name: planepublicdeploy + plane-deploy: + container_name: planedeploy image: makeplane/plane-space:latest restart: always - command: node apps/space/server.js + command: node apps/space/server.js space env_file: - .env environment: diff --git a/docker-compose.yml b/docker-compose.yml index 07aa79f3687..d1ffca809ff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -64,7 +64,7 @@ services: container_name: planedeploy build: context: . - dockerfile: ./apps/space/Dockerfile.space + dockerfile: ./apps/space/Dockerfile.space space args: NEXT_PUBLIC_API_BASE_URL: http://localhost:8000 restart: always From 106400a3f43444bda8b40bbe224403c04caf3db4 Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Mon, 21 Aug 2023 18:11:27 +0530 Subject: [PATCH 18/18] dev: revert workspace space page --- apps/space/app/[workspace_slug]/page.tsx | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/apps/space/app/[workspace_slug]/page.tsx b/apps/space/app/[workspace_slug]/page.tsx index 715027a8904..c35662f5a62 100644 --- a/apps/space/app/[workspace_slug]/page.tsx +++ b/apps/space/app/[workspace_slug]/page.tsx @@ -1,17 +1,7 @@ "use client"; -// next imports -import { useRouter, useParams, useSearchParams } from "next/navigation"; - -const WorkspaceProjectPage = () => { - const routerParams = useParams(); - const { workspace_slug } = routerParams as { workspace_slug: string }; - - return ( -
- Plane {workspace_slug || "nahh"} -
- ); -}; +const WorkspaceProjectPage = () => ( +
Plane Workspace Space
+); export default WorkspaceProjectPage;