Merge pull request 'Added excalidraw' (#3) from excalidraw into main

Reviewed-on: #3
This commit is contained in:
gec 2023-09-29 08:12:01 +00:00
commit d7e433f3c2
22 changed files with 8755 additions and 9 deletions

View file

@ -107,9 +107,17 @@ release-to-forgejo:
script:
- pyb publish_artifacts
jitsi-image-test-publish:
jitsi-web-image-publish:
<<: *img
<<: *tag_only
stage: image
script:
- cd infrastructure/app && pyb image publish
- cd infrastructure/web && pyb image publish
jitsi-excalidraw-backend-image-publish:
<<: *img
<<: *tag_only
stage: image
script:
- cd infrastructure/excalidraw-backend && pyb image publish

View file

@ -22,7 +22,8 @@ def initialize(project):
"release_primary_build_file": "project.clj",
"release_secondary_build_files": [
"package.json",
"infrastructure/app/build.py",
"infrastructure/web/build.py",
"infrastructure/excalidraw-backend/build.py",
],
"release_artifact_server_url": "https://repo.prod.meissa.de",
"release_organisation": "meissa",
@ -78,7 +79,7 @@ def package_frontend(project):
run(
"cp public/js/main.js target/frontend-build/c4k-jitsi.js",
shell=True,
check=True,
check=Tc4k/c4k-jitsi/infrastructure/excalidraw-backend/excalidraw-backend/package-lock.json c4k/c4k-jitsi/infrastructure/excalidraw-backend/excalidraw-backend/package.json c4k/c4k-jitsi/infrastructure/excalidraw-backend/excalidraw-backend/tsconfig.json c4k/c4k-jitsi/infrastructure/excalidraw-backend/excalidraw-backend/srcrue,
)
run(
"sha256sum target/frontend-build/c4k-jitsi.js > target/frontend-build/c4k-jitsi.js.sha256",

View file

@ -0,0 +1,57 @@
from os import environ
from datetime import datetime
from pybuilder.core import task, init
from ddadevops import *
name = "c4k-jitsi"
MODULE = "excalidraw-backend"
PROJECT_ROOT_PATH = "../.."
version = "1.4.2-SNAPSHOT"
@init
def initialize(project):
image_tag = version
if "dev" in image_tag:
image_tag += datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
input = {
"name": name,
"module": MODULE,
"stage": "notused",
"project_root_path": PROJECT_ROOT_PATH,
"build_types": ["IMAGE"],
"mixin_types": [],
"image_naming": "NAME_AND_MODULE",
"image_tag": f"{image_tag}",
}
project.build_depends_on("ddadevops>=4.7.0")
build = DevopsImageBuild(project, input)
build.initialize_build_dir()
@task
def image(project):
build = get_devops_build(project)
build.image()
@task
def drun(project):
build = get_devops_build(project)
build.drun()
@task
def test(project):
build = get_devops_build(project)
build.test()
@task
def publish(project):
build = get_devops_build(project)
build.dockerhub_login()
build.dockerhub_publish()

View file

@ -0,0 +1,14 @@
# Taken from: https://github.com/jitsi/excalidraw-backend
FROM node:16.17-slim
WORKDIR /excalidraw-backend
COPY resources/package.json resources/package-lock.json resources/tsconfig.json resources/src ./
RUN npm install
RUN npm run build
EXPOSE 80
EXPOSE 9090
CMD ["npm", "start"]

View file

@ -0,0 +1 @@
!package-lock.json

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,52 @@
{
"name": "excalidraw-backend",
"version": "1.0.0",
"main": "src/index.js",
"description": "Excalidraw backend",
"repository": {
"type": "git",
"url": "https://github.com/jitsi/excalidraw-backend"
},
"private": true,
"engines": {
"node": ">=14.0.0",
"npm": ">=7.0.0"
},
"dependencies": {
"@types/debug": "4.1.5",
"@types/express": "4.17.11",
"@types/node": "14.14.31",
"@types/socket.io": "2.1.4",
"cross-env": "^7.0.3",
"debug": "4.3.1",
"dotenv": "^10.0.0",
"express": "4.17.1",
"socket.io": "^2.5.0",
"socket.io-prometheus-metrics": "^1.0.6",
"ts-node-dev": "^1.1.8",
"typescript": "4.2.3"
},
"license": "MIT",
"scripts": {
"build": "tsc",
"lint": "eslint .",
"lint-fix": "eslint . --fix",
"start": "tsc && node dist/index.js",
"start:local": "tsc && DEBUG='engine,app,socket.io:client,server' node dist/index.js",
"start:dev": "cross-env NODE_ENV=development ts-node-dev --respawn --transpile-only src/index.ts"
},
"devDependencies": {
"@jitsi/eslint-config": "^4.1.0",
"@types/dotenv": "^8.2.0",
"@typescript-eslint/eslint-plugin": "5.30.5",
"@typescript-eslint/parser": "5.30.4",
"eslint": "8.1.0",
"eslint-plugin-import": "2.25.2",
"eslint-plugin-jsdoc": "37.0.3",
"eslint-plugin-typescript-sort-keys": "^2.1.0"
},
"optionalDependencies": {
"bufferutil": "^4.0.6",
"utf-8-validate": "^5.0.9"
}
}

View file

@ -0,0 +1,7 @@
module.exports = {
extends: [
'@jitsi/eslint-config',
'@jitsi/eslint-config/jsdoc',
'@jitsi/eslint-config/typescript',
],
};

View file

@ -0,0 +1,107 @@
// Taken from: https://github.com/jitsi/excalidraw-backend
import debug from 'debug';
import dotenv from 'dotenv';
import express from 'express';
import http from 'http';
import socketIO from 'socket.io';
import * as prometheus from 'socket.io-prometheus-metrics';
const serverDebug = debug('server');
dotenv.config(
process.env.NODE_ENV === 'development'
? { path: '.env.development' }
: { path: '.env.production' }
);
const app = express();
const port = process.env.PORT || 80; // default port to listen
app.get('/', (req, res) => {
res.send('Excalidraw backend is up :)');
});
const server = http.createServer(app);
server.listen(port, () => {
serverDebug(`listening on port: ${port}`);
});
const io = socketIO(server, {
handlePreflightRequest: (req, res) => {
const headers = {
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
'Access-Control-Allow-Origin': req.header?.origin ?? 'https://meet.jit.si',
'Access-Control-Allow-Credentials': true
};
res.writeHead(200, headers);
res.end();
},
maxHttpBufferSize: 10e6,
pingTimeout: 10000
});
// listens on host:9090/metrics
prometheus.metrics(io, {
collectDefaultMetrics: true
});
io.on('connection', socket => {
serverDebug(`connection established! ${socket.conn.request.url}`);
io.to(`${socket.id}`).emit('init-room');
socket.on('join-room', roomID => {
serverDebug(`${socket.id} has joined ${roomID} for url ${socket.conn.request.url}`);
socket.join(roomID);
if (io.sockets.adapter.rooms[roomID].length <= 1) {
io.to(`${socket.id}`).emit('first-in-room');
} else {
socket.broadcast.to(roomID).emit('new-user', socket.id);
}
io.in(roomID).emit(
'room-user-change',
Object.keys(io.sockets.adapter.rooms[roomID].sockets)
);
});
socket.on(
'server-broadcast',
(roomID: string, encryptedData: ArrayBuffer, iv: Uint8Array) => {
socket.broadcast.to(roomID).emit('client-broadcast', encryptedData, iv);
}
);
socket.on(
'server-volatile-broadcast',
(roomID: string, encryptedData: ArrayBuffer, iv: Uint8Array) => {
socket.volatile.broadcast
.to(roomID)
.emit('client-broadcast', encryptedData, iv);
}
);
socket.on('disconnecting', () => {
const rooms = io.sockets.adapter.rooms;
for (const roomID of Object.keys(socket.rooms)) {
const clients = Object.keys(rooms[roomID].sockets).filter(id => id !== socket.id);
if (roomID !== socket.id) {
socket.to(roomID).emit('user has left', socket.id);
}
if (clients.length > 0) {
socket.broadcast.to(roomID).emit('room-user-change', clients);
}
}
});
socket.on('disconnect', (reason, details) => {
serverDebug(
`${socket.id} was disconnected from url ${socket.conn.request.url} for the following reason: ${reason}
${JSON.stringify(details)}`
);
socket.removeAllListeners();
});
});

View file

@ -0,0 +1,17 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"strict": true,
"moduleResolution": "Node",
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"isolatedModules": true,
"outDir": "dist"
}
}

View file

@ -4,7 +4,7 @@ from pybuilder.core import task, init
from ddadevops import *
name = "c4k-jitsi"
MODULE = "app"
MODULE = "web"
PROJECT_ROOT_PATH = "../.."
version = "1.4.3-SNAPSHOT"
@ -22,7 +22,7 @@ def initialize(project):
"project_root_path": PROJECT_ROOT_PATH,
"build_types": ["IMAGE"],
"mixin_types": [],
"image_naming": "NAME_ONLY",
"image_naming": "NAME_AND_MODULE",
"image_tag": f"{image_tag}",
}

View file

View file

@ -34,8 +34,11 @@
(jitsi/generate-jvb-service)
(jitsi/generate-web-service)
(jitsi/generate-etherpad-service)
(jitsi/generate-deployment config)]
(jitsi/generate-excalidraw-backend-service)
(jitsi/generate-deployment config)
(jitsi/generate-excalidraw-deployment)]
(jitsi/generate-ingress-web config)
(jitsi/generate-ingress-etherpad config)
(jitsi/generate-ingress-excalidraw-backend config)
(when (:contains? config :mon-cfg)
(mon/generate (:mon-cfg config) (:mon-auth auth)))))))

View file

@ -51,6 +51,15 @@
:fqdns [(str "etherpad." (:fqdn config))]}
config)))
(defn-spec generate-ingress-excalidraw-backend cp/map-or-seq?
[config config?]
(ing/generate-ingress-and-cert
(merge
{:service-name "excalidraw-backend"
:service-port 3002
:fqdns [(str "excalidraw-backend." (:fqdn config))]}
config)))
(defn-spec generate-secret-jitsi cp/map-or-seq?
[auth auth?]
(let [{:keys [jvb-auth-password jicofo-auth-password jicofo-component-secret]} auth]
@ -69,6 +78,9 @@
(defn-spec generate-etherpad-service cp/map-or-seq? []
(yaml/load-as-edn "jitsi/etherpad-service.yaml"))
(defn-spec generate-excalidraw-backend-service cp/map-or-seq? []
(yaml/load-as-edn "jitsi/excalidraw-backend-service.yaml"))
(defn-spec generate-deployment cp/map-or-seq?
[config config?]
(let [{:keys [fqdn]} config]
@ -76,4 +88,9 @@
(yaml/load-as-edn "jitsi/deployment.yaml")
(cm/replace-all-matching-values-by-new-value "REPLACE_JITSI_FQDN" fqdn)
(cm/replace-all-matching-values-by-new-value "REPLACE_ETHERPAD_URL"
(str "https://etherpad." fqdn "/p/")))))
(str "https://etherpad." fqdn "/p/"))
(cm/replace-all-matching-values-by-new-value "REPLACE_EXCALIDRAW_BACKEND_URL"
(str "https://excalidraw-backend." fqdn)))))
(defn-spec generate-excalidraw-deployment cp/map-or-seq? []
(yaml/load-as-edn "jitsi/excalidraw-deployment.yaml"))

View file

@ -68,7 +68,7 @@ spec:
- name: JVB_TCP_HARVESTER_DISABLED
value: "true"
- name: web
image: domaindrivenarchitecture/c4k-jitsi
image: domaindrivenarchitecture/c4k-jitsi-web
imagePullPolicy: IfNotPresent
env:
- name: PUBLIC_URL
@ -97,6 +97,10 @@ spec:
value: "true"
- name: ETHERPAD_PUBLIC_URL
value: REPLACE_ETHERPAD_URL
- name: WHITEBOARD_ENABLED
value: "true"
- name: WHITEBOARD_COLLAB_SERVER_PUBLIC_URL
value: REPLACE_EXCALIDRAW_BACKEND_URL
- name: jvb
image: jitsi/jvb:stable-8922-1
imagePullPolicy: IfNotPresent

View file

@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
labels:
service: excalidraw-backend
name: excalidraw-backend
spec:
ports:
- name: excalidraw-backend
port: 3002
targetPort: 80
selector:
app: excalidraw-backend

View file

@ -0,0 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: excalidraw-backend
name: excalidraw-backend
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: excalidraw-backend
template:
metadata:
labels:
app: excalidraw-backend
spec:
containers:
- name: excalidraw-backend
image: domaindrivenarchitecture/c4k-jitsi-excalidraw-backend