dev: updated dockerfile.space and start and replace script

This commit is contained in:
NarayanBavisetti 2023-08-21 17:11:24 +05:30
parent f385b762af
commit 4ae34f37b8
10 changed files with 84 additions and 62 deletions

View File

@ -33,8 +33,8 @@ RUN yarn turbo run build --filter=app
ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \ ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \
BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL BUILT_NEXT_PUBLIC_API_BASE_URL=$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} 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 FROM node:18-alpine AS runner
WORKDIR /app WORKDIR /app

View File

@ -15,36 +15,36 @@ export interface BubbleMenuItem {
type EditorBubbleMenuProps = Omit<BubbleMenuProps, "children">; type EditorBubbleMenuProps = Omit<BubbleMenuProps, "children">;
export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => { export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props: any) => {
const items: BubbleMenuItem[] = [ const items: BubbleMenuItem[] = [
{ {
name: "bold", name: "bold",
isActive: () => props.editor!.isActive("bold"), isActive: () => props.editor?.isActive("bold"),
command: () => props.editor!.chain().focus().toggleBold().run(), command: () => props.editor?.chain().focus().toggleBold().run(),
icon: BoldIcon, icon: BoldIcon,
}, },
{ {
name: "italic", name: "italic",
isActive: () => props.editor!.isActive("italic"), isActive: () => props.editor?.isActive("italic"),
command: () => props.editor!.chain().focus().toggleItalic().run(), command: () => props.editor?.chain().focus().toggleItalic().run(),
icon: ItalicIcon, icon: ItalicIcon,
}, },
{ {
name: "underline", name: "underline",
isActive: () => props.editor!.isActive("underline"), isActive: () => props.editor?.isActive("underline"),
command: () => props.editor!.chain().focus().toggleUnderline().run(), command: () => props.editor?.chain().focus().toggleUnderline().run(),
icon: UnderlineIcon, icon: UnderlineIcon,
}, },
{ {
name: "strike", name: "strike",
isActive: () => props.editor!.isActive("strike"), isActive: () => props.editor?.isActive("strike"),
command: () => props.editor!.chain().focus().toggleStrike().run(), command: () => props.editor?.chain().focus().toggleStrike().run(),
icon: StrikethroughIcon, icon: StrikethroughIcon,
}, },
{ {
name: "code", name: "code",
isActive: () => props.editor!.isActive("code"), isActive: () => props.editor?.isActive("code"),
command: () => props.editor!.chain().focus().toggleCode().run(), command: () => props.editor?.chain().focus().toggleCode().run(),
icon: CodeIcon, icon: CodeIcon,
}, },
]; ];

View File

@ -1,63 +1,70 @@
FROM node:18-alpine AS base FROM node:18-alpine AS builder
# [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 add --no-cache libc6-compat
RUN apk update # Set working directory
# Installing turbo, copying monorepo and executing prune
WORKDIR /app WORKDIR /app
ENV NEXT_PUBLIC_API_BASE_URL=http://NEXT_PUBLIC_API_BASE_URL_PLACEHOLDER
RUN yarn global add turbo RUN yarn global add turbo
COPY . . COPY . .
# plane-deploy pruned as /app/out/json (deps) and /app/out/full (plane-deploy) RUN turbo prune --scope=space --docker
RUN turbo prune --scope=plane-deploy --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 --no-cache libc6-compat
RUN apk add tree
RUN apk update
WORKDIR /app 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/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock 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 ) # Build the project
COPY --from=builder ./app/out/full . COPY --from=builder /app/out/full/ .
RUN yarn turbo run build --filter=plane-deploy COPY turbo.json turbo.json
# CMD tree ./apps -I 'node_modules' 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 RUN yarn turbo run build --filter=space
FROM base AS runner
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 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 addgroup --system --gid 1001 plane
RUN adduser --system --uid 1001 captain RUN adduser --system --uid 1001 captain
USER captain USER captain
# transporting package files from installer
COPY --from=installer /app/apps/space/next.config.js . COPY --from=installer /app/apps/space/next.config.js .
COPY --from=installer /app/apps/space/package.json . 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/standalone ./
COPY --from=installer --chown=captain:plane /app/apps/space/.next ./apps/space/.next COPY --from=installer --chown=captain:plane /app/apps/space/.next ./apps/space/.next
# Start the server ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
CMD node apps/space/server.js 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

View File

@ -1,7 +1,17 @@
"use client"; "use client";
const WorkspaceProjectPage = () => ( // next imports
<div className="relative w-screen h-screen flex justify-center items-center text-5xl">Plane Workspace Space</div> import { useRouter, useParams, useSearchParams } from "next/navigation";
const WorkspaceProjectPage = () => {
const routerParams = useParams();
const { workspace_slug } = routerParams as { workspace_slug: string };
return (
<div className="relative w-screen h-screen flex justify-center items-center text-5xl">
Plane {workspace_slug || "nahh"}
</div>
); );
};
export default WorkspaceProjectPage; export default WorkspaceProjectPage;

View File

@ -1,5 +1,5 @@
{ {
"name": "plane-deploy", "name": "space",
"version": "0.0.1", "version": "0.0.1",
"private": true, "private": true,
"scripts": { "scripts": {

View File

@ -41,12 +41,14 @@ services:
dockerfile: ./apps/app/Dockerfile.web dockerfile: ./apps/app/Dockerfile.web
args: args:
NEXT_PUBLIC_API_BASE_URL: http://localhost:8000 NEXT_PUBLIC_API_BASE_URL: http://localhost:8000
NEXT_PUBLIC_DEPLOY_URL: http://localhost/spaces
restart: always restart: always
command: /usr/local/bin/start.sh command: /usr/local/bin/start.sh apps/app/server.js app
env_file: env_file:
- .env - .env
environment: environment:
NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_API_BASE_URL} 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_GOOGLE_CLIENTID: "0"
NEXT_PUBLIC_GITHUB_APP_NAME: "0" NEXT_PUBLIC_GITHUB_APP_NAME: "0"
NEXT_PUBLIC_GITHUB_ID: "0" NEXT_PUBLIC_GITHUB_ID: "0"
@ -58,13 +60,15 @@ services:
depends_on: depends_on:
- plane-api - plane-api
- plane-worker - plane-worker
public-deploy: plane-deploy:
container_name: planepublicdeploy container_name: planedeploy
build: build:
context: . context: .
dockerfile: ./apps/space/Dockerfile.space dockerfile: ./apps/space/Dockerfile.space
args:
NEXT_PUBLIC_API_BASE_URL: http://localhost:8000
restart: always restart: always
command: node apps/space/server.js command: /usr/local/bin/start.sh apps/space/server.js space
env_file: env_file:
- .env - .env
environment: environment:

View File

@ -15,8 +15,8 @@ server {
proxy_pass http://planefrontend:3000/; proxy_pass http://planefrontend:3000/;
} }
location /spaces { location /spaces/ {
proxy_pass http://planepublicdeploy:4000/; proxy_pass http://planedeploy:3000/;
} }
location /api/ { location /api/ {

View File

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
FROM=$1 FROM=$1
TO=$2 TO=$2
DIRECTORY=$3
if [ "${FROM}" = "${TO}" ]; then if [ "${FROM}" = "${TO}" ]; then
echo "Nothing to replace, the value is already set to ${TO}." 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. # Only perform action if $FROM and $TO are different.
echo "Replacing all statically built instances of $FROM with this string $TO ." 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" "{}"

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# cp ./.env.example ./.env cp ./.env.example ./.env
# Export for tr error in mac # Export for tr error in mac
export LC_ALL=C export LC_ALL=C

View File

@ -3,7 +3,7 @@ set -x
# Replace the statically built BUILT_NEXT_PUBLIC_API_BASE_URL with run-time NEXT_PUBLIC_API_BASE_URL # 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. # 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.." echo "Starting Plane Frontend.."
node apps/app/server.js & node apps/space/server.js node $1