Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f001bfa
[WEB-1116] feat: pages realtime sync (#5057)
aaryan610 Jul 22, 2024
5c668d4
fix: docker related fixes
sriramveeraghanta Jul 26, 2024
eb93202
fix: module type fixes
sriramveeraghanta Jul 31, 2024
0ed9620
fix: nginx update
sriramveeraghanta Jul 31, 2024
a4c03a0
fix: adding live server workflow
sriramveeraghanta Jul 31, 2024
87e94fc
fix: workflow fixes
sriramveeraghanta Jul 31, 2024
f831153
fix: docker compose fixes
sriramveeraghanta Jul 31, 2024
3f289ce
fix: workflow fixes
sriramveeraghanta Jul 31, 2024
394894b
fix: merge conflicts
sriramveeraghanta Jul 31, 2024
ada5e5d
fix: path config
sriramveeraghanta Jul 31, 2024
988cf4d
fix: docker compose warnings
sriramveeraghanta Jul 31, 2024
c220472
fix: nginx port forwarding
sriramveeraghanta Jul 31, 2024
fcaeab1
fix: update docker compose with new env
sriramveeraghanta Aug 1, 2024
5db5cf9
fix: env var fixes
sriramveeraghanta Aug 1, 2024
7cd2be0
fix: error handling
sriramveeraghanta Aug 1, 2024
b573f81
fix: docker compose env var
sriramveeraghanta Aug 1, 2024
a19c168
fix: compose fixes
sriramveeraghanta Aug 1, 2024
4712179
chore: update server start message
aaryan610 Aug 1, 2024
754006e
chore: handle errors
aaryan610 Aug 1, 2024
65f06f8
fix: build errors
aaryan610 Aug 1, 2024
6868ac4
chore: update port
aaryan610 Aug 1, 2024
e654a27
chore: update server port
aaryan610 Aug 1, 2024
bf7bcc9
chore: show error on authentication fail
aaryan610 Aug 2, 2024
fcfac69
chore: show error on authentication fail
aaryan610 Aug 2, 2024
bc7e217
feat: add redis extension
Palanikannan1437 Aug 22, 2024
4de8c2c
fix: merge conflicts resolved from preview
aaryan610 Aug 27, 2024
8231ca5
fix: merge conflicts resolved from preview
aaryan610 Aug 29, 2024
7e39663
Merge branch 'preview' of https://github.com/makeplane/plane into pag…
aaryan610 Sep 2, 2024
df579ae
chore: updated restore version logic
aaryan610 Sep 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/build-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
build_admin: ${{ steps.changed_files.outputs.admin_any_changed }}
build_space: ${{ steps.changed_files.outputs.space_any_changed }}
build_web: ${{ steps.changed_files.outputs.web_any_changed }}
build_live: ${{ steps.changed_files.outputs.live_any_changed }}

steps:
- id: set_env_variables
Expand Down Expand Up @@ -79,6 +80,13 @@ jobs:
- 'yarn.lock'
- 'tsconfig.json'
- 'turbo.json'
live:
- live/**
- packages/**
- 'package.json'
- 'yarn.lock'
- 'tsconfig.json'
- 'turbo.json'

branch_build_push_web:
if: ${{ needs.branch_build_setup.outputs.build_web == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }}
Expand Down Expand Up @@ -288,6 +296,58 @@ jobs:
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}

branch_build_push_live:
if: ${{ needs.branch_build_setup.outputs.build_live == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }}
runs-on: ubuntu-20.04
needs: [branch_build_setup]
env:
LIVE_TAG: makeplane/plane-live:${{ needs.branch_build_setup.outputs.gh_branch_name }}
TARGET_BRANCH: ${{ needs.branch_build_setup.outputs.gh_branch_name }}
BUILDX_DRIVER: ${{ needs.branch_build_setup.outputs.gh_buildx_driver }}
BUILDX_VERSION: ${{ needs.branch_build_setup.outputs.gh_buildx_version }}
BUILDX_PLATFORMS: ${{ needs.branch_build_setup.outputs.gh_buildx_platforms }}
BUILDX_ENDPOINT: ${{ needs.branch_build_setup.outputs.gh_buildx_endpoint }}
steps:
- name: Set Live Docker Tag
run: |
if [ "${{ github.event_name }}" == "release" ]; then
TAG=makeplane/plane-live:stable,makeplane/plane-live:${{ github.event.release.tag_name }}
elif [ "${{ env.TARGET_BRANCH }}" == "master" ]; then
TAG=makeplane/plane-live:latest
else
TAG=${{ env.LIVE_TAG }}
fi
echo "LIVE_TAG=${TAG}" >> $GITHUB_ENV

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: ${{ env.BUILDX_DRIVER }}
version: ${{ env.BUILDX_VERSION }}
endpoint: ${{ env.BUILDX_ENDPOINT }}

- name: Check out the repo
uses: actions/checkout@v4

- name: Build and Push Live Server to Docker Hub
uses: docker/build-push-action@v5.1.0
with:
context: .
file: ./live/Dockerfile.live
platforms: ${{ env.BUILDX_PLATFORMS }}
tags: ${{ env.LIVE_TAG }}
push: true
env:
DOCKER_BUILDKIT: 1
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}

branch_build_push_proxy:
if: ${{ needs.branch_build_setup.outputs.build_proxy == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }}
runs-on: ubuntu-20.04
Expand Down
4 changes: 2 additions & 2 deletions admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"postcss": "^8.4.38",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.51.0",
"react-hook-form": "7.51.5",
"swr": "^2.2.4",
"tailwindcss": "3.3.2",
"uuid": "^9.0.1",
Expand All @@ -47,4 +47,4 @@
"tsconfig": "*",
"typescript": "^5.4.2"
}
}
}
1 change: 1 addition & 0 deletions apiserver/plane/app/views/page/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ def partial_update(self, request, slug, project_id, pk):
# Store the updated binary data
page.description_binary = new_binary_data
page.description_html = request.data.get("description_html")
page.description = request.data.get("description")
page.save()
# Return a success response
page_version.delay(
Expand Down
23 changes: 17 additions & 6 deletions deploy/selfhost/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ x-app-env: &app-env
- NGINX_PORT=${NGINX_PORT:-80}
- WEB_URL=${WEB_URL:-http://localhost}
- DEBUG=${DEBUG:-0}
- SENTRY_DSN=${SENTRY_DSN}
- SENTRY_DSN=${SENTRY_DSN:-""}
- SENTRY_ENVIRONMENT=${SENTRY_ENVIRONMENT:-"production"}
- CORS_ALLOWED_ORIGINS=${CORS_ALLOWED_ORIGINS}
- CORS_ALLOWED_ORIGINS=${CORS_ALLOWED_ORIGINS:-}
# Gunicorn Workers
- GUNICORN_WORKERS=${GUNICORN_WORKERS:-1}
#DB SETTINGS
Expand Down Expand Up @@ -34,10 +34,8 @@ x-app-env: &app-env
- MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD:-"secret-key"}
- BUCKET_NAME=${BUCKET_NAME:-uploads}
- FILE_SIZE_LIMIT=${FILE_SIZE_LIMIT:-5242880}
# Admin and Space URLs
- ADMIN_BASE_URL=${ADMIN_BASE_URL}
- SPACE_BASE_URL=${SPACE_BASE_URL}
- APP_BASE_URL=${APP_BASE_URL}
# Live server env
- API_BASE_URL=${API_BASE_URL:-http://api:8000}

services:
web:
Expand Down Expand Up @@ -80,6 +78,19 @@ services:
- api
- web

live:
<<: *app-env
image: ${DOCKERHUB_USER:-makeplane}/plane-live:${APP_RELEASE:-stable}
platform: ${DOCKER_PLATFORM:-}
pull_policy: if_not_present
restart: unless-stopped
command: node live/dist/server.js live
deploy:
replicas: ${LIVE_REPLICAS:-1}
depends_on:
- api
- web

api:
<<: *app-env
image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-stable}
Expand Down
14 changes: 14 additions & 0 deletions docker-compose-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ services:
- worker
- web

live:
build:
context: .
dockerfile: ./live/Dockerfile.dev
restart: unless-stopped
networks:
- dev_env
volumes:
- ./live:/app/live
depends_on:
- api
- worker
- web

api:
build:
context: ./apiserver
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ services:
- plane-db
- plane-redis

live:
container_name: plane-live
build:
context: .
dockerfile: ./live/Dockerfile.live
args:
DOCKER_BUILDKIT: 1
restart: always
command: node live/dist/server.js

plane-db:
container_name: plane-db
image: postgres:15.7-alpine
Expand Down
1 change: 1 addition & 0 deletions live/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
API_BASE_URL="http://api:8000"
13 changes: 13 additions & 0 deletions live/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:18-alpine
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app


COPY . .
RUN yarn global add turbo
RUN yarn install
EXPOSE 3003

VOLUME [ "/app/node_modules", "/app/live/node_modules"]
CMD ["yarn","dev", "--filter=live"]
44 changes: 44 additions & 0 deletions live/Dockerfile.live
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM node:18-alpine AS base
# The web Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update this Dockerfile, the Dockerfile in the web workspace and copy that over to Dockerfile in the docs.

FROM base AS builder
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune live --docker

# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app

# First install 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

# Build the project and its dependencies
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json

RUN yarn turbo build --filter=live

FROM base AS runner
WORKDIR /app

# Don't run production as root
RUN addgroup --system --gid 1001 expressjs
RUN adduser --system --uid 1001 expressjs
USER expressjs

COPY --from=installer /app .
# COPY --from=installer /app/live/node_modules ./node_modules

EXPOSE 3000
44 changes: 44 additions & 0 deletions live/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "live",
"version": "0.22.0",
"description": "",
"main": "./src/server.ts",
"private": true,
"type": "module",
"scripts": {
"build": "tsc",
"start": "node dist/server.js",
"dev": "PORT=3003 nodemon --exec \"node -r esbuild-register ./src/server.ts\" -e .ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@hocuspocus/extension-database": "^2.11.3",
"@hocuspocus/extension-logger": "^2.11.3",
"@hocuspocus/extension-redis": "^2.13.5",
"@hocuspocus/server": "^2.11.3",
"@plane/editor": "*",
"@plane/types": "*",
"@tiptap/core": "^2.4.0",
"@tiptap/html": "^2.3.0",
"axios": "^1.7.2",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"express-ws": "^5.0.2",
"lodash": "^4.17.21",
"y-prosemirror": "^1.2.9",
"y-protocols": "^1.0.6",
"yjs": "^13.6.14"
},
"devDependencies": {
"@types/dotenv": "^8.2.0",
"@types/express": "^4.17.21",
"@types/express-ws": "^3.0.4",
"@types/node": "^20.14.9",
"tsup": "^7.2.0",
"nodemon": "^3.1.0",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
}
}
2 changes: 2 additions & 0 deletions live/src/ce/types/common.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line @typescript-eslint/ban-types
export type TAdditionalDocumentTypes = {}
Comment on lines +1 to +2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define TAdditionalDocumentTypes with explicit properties instead of using {}.

The empty object type {} means "any non-nullable value" in TypeScript, which defeats the purpose of type checking and can lead to errors.

Define the type with explicit properties and their types based on the expected additional document types. For example:

export type TAdditionalDocumentTypes = {
  // Define properties and their types here
  // Example:
  // customDoc: {
  //   id: string;
  //   name: string;
  //   // ...
  // };
};

If there are no additional document types expected at the moment, consider removing the type declaration altogether until it is needed.

Let me know if you need help defining the properties and their types for TAdditionalDocumentTypes. I can assist you in updating the type definition based on the expected additional document types in your application.

Tools
Biome

[error] 2-2: Don't use '{}' as a type.

Prefer explicitly define the object shape. '{}' means "any non-nullable value".

(lint/complexity/noBannedTypes)

62 changes: 62 additions & 0 deletions live/src/core/lib/authentication.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { ConnectionConfiguration } from "@hocuspocus/server";
// services
import { UserService } from "../services/user.service.js";
// types
import { TDocumentTypes } from "../types/common.js";

const userService = new UserService();

type Props = {
connection: ConnectionConfiguration;
cookie: string;
params: URLSearchParams;
token: string;
};

export const handleAuthentication = async (props: Props) => {
const { connection, cookie, params, token } = props;
// params
const workspaceSlug = params.get("workspaceSlug")?.toString();
const projectId = params.get("projectId")?.toString();
const documentType = params.get("documentType")?.toString() as
| TDocumentTypes
| undefined;
// fetch current user info
let response;
try {
response = await userService.currentUser(cookie);
} catch (error) {
console.error("Failed to fetch current user:", error);
throw error;
}
if (response.id !== token) {
throw Error("Authentication failed: Token doesn't match the current user.");
}

if (documentType === "project_page") {
if (!workspaceSlug || !projectId) {
throw Error(
"Authentication failed: Incomplete query params. Either workspaceSlug or projectId is missing."
);
}
// fetch current user's roles
const workspaceRoles = await userService.getUserAllProjectsRole(
workspaceSlug,
cookie
);
const currentProjectRole = workspaceRoles[projectId];
// make the connection read only for roles lower than a member
if (currentProjectRole < 15) {
connection.readOnly = true;
}
} else {
throw Error("Authentication failed: Invalid document type provided.");
}

return {
user: {
id: response.id,
name: response.display_name,
},
};
};
Loading