-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduce tldraw to sc-server --------- Co-authored-by: Błażej Szczepanowski <[email protected]> Co-authored-by: davwas <[email protected]> Co-authored-by: Tomasz Wiaderek <[email protected]> Co-authored-by: wiaderwek <[email protected]> Co-authored-by: Thomas Feldtkeller <[email protected]> Co-authored-by: mamutmk5 <[email protected]>
- Loading branch information
1 parent
af700bb
commit 9f69eed
Showing
98 changed files
with
3,264 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
ansible/roles/schulcloud-server-core/templates/tldraw-deployment.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: tldraw-deployment | ||
namespace: {{ NAMESPACE }} | ||
labels: | ||
app: tldraw-server | ||
app.kubernetes.io/part-of: schulcloud-verbund | ||
app.kubernetes.io/version: {{ SCHULCLOUD_SERVER_IMAGE_TAG }} | ||
app.kubernetes.io/name: tldraw-server | ||
app.kubernetes.io/component: tldraw | ||
app.kubernetes.io/managed-by: ansible | ||
git.branch: {{ SCHULCLOUD_SERVER_BRANCH_NAME }} | ||
git.repo: {{ SCHULCLOUD_SERVER_REPO_NAME }} | ||
spec: | ||
replicas: {{ TLDRAW_SERVER_REPLICAS|default("1", true) }} | ||
strategy: | ||
type: RollingUpdate | ||
rollingUpdate: | ||
maxSurge: 1 | ||
#maxUnavailable: 1 | ||
revisionHistoryLimit: 4 | ||
paused: false | ||
selector: | ||
matchLabels: | ||
app: tldraw-server | ||
template: | ||
metadata: | ||
labels: | ||
app: tldraw-server | ||
app.kubernetes.io/part-of: schulcloud-verbund | ||
app.kubernetes.io/version: {{ SCHULCLOUD_SERVER_IMAGE_TAG }} | ||
app.kubernetes.io/name: tldraw-server | ||
app.kubernetes.io/component: tldraw | ||
app.kubernetes.io/managed-by: ansible | ||
git.branch: {{ SCHULCLOUD_SERVER_BRANCH_NAME }} | ||
git.repo: {{ SCHULCLOUD_SERVER_REPO_NAME }} | ||
spec: | ||
securityContext: | ||
runAsUser: 1000 | ||
runAsGroup: 1000 | ||
fsGroup: 1000 | ||
runAsNonRoot: true | ||
containers: | ||
- name: tldraw | ||
image: {{ SCHULCLOUD_SERVER_IMAGE }}:{{ SCHULCLOUD_SERVER_IMAGE_TAG }} | ||
imagePullPolicy: IfNotPresent | ||
ports: | ||
- containerPort: 3345 | ||
name: tldraw-ws | ||
protocol: TCP | ||
- containerPort: 3349 | ||
name: tldraw-http | ||
protocol: TCP | ||
envFrom: | ||
- configMapRef: | ||
name: api-configmap | ||
- secretRef: | ||
name: api-secret | ||
command: ['npm', 'run', 'nest:start:tldraw:prod'] | ||
resources: | ||
limits: | ||
cpu: {{ TLDRAW_EDITOR_CPU_LIMITS|default("2000m", true) }} | ||
memory: {{ TLDRAW_EDITOR_MEMORY_LIMITS|default("4Gi", true) }} | ||
requests: | ||
cpu: {{ TLDRAW_EDITOR_CPU_REQUESTS|default("100m", true) }} | ||
memory: {{ TLDRAW_EDITOR_MEMORY_REQUESTS|default("150Mi", true) }} |
42 changes: 42 additions & 0 deletions
42
ansible/roles/schulcloud-server-core/templates/tldraw-ingress.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: {{ NAMESPACE }}-tldraw-ingress | ||
namespace: {{ NAMESPACE }} | ||
annotations: | ||
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" | ||
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" | ||
nginx.ingress.kubernetes.io/proxy-body-size: "{{ INGRESS_MAX_BODY_SIZE|default("2560") }}m" | ||
nginx.org/client-max-body-size: "{{ INGRESS_MAX_BODY_SIZE|default("2560") }}m" | ||
# The following properties added with BC-3606. | ||
# The header size of the request is too big. For e.g. state and the permanent growing jwt. | ||
# Nginx throws away the Location header, resulting in the 502 Bad Gateway. | ||
nginx.ingress.kubernetes.io/client-header-buffer-size: 100k | ||
nginx.ingress.kubernetes.io/http2-max-header-size: 96k | ||
nginx.ingress.kubernetes.io/large-client-header-buffers: 4 100k | ||
nginx.ingress.kubernetes.io/proxy-buffer-size: 96k | ||
{% if CLUSTER_ISSUER is defined %} | ||
cert-manager.io/cluster-issuer: {{ CLUSTER_ISSUER }} | ||
{% endif %} | ||
|
||
spec: | ||
ingressClassName: nginx | ||
{% if CLUSTER_ISSUER is defined or (TLS_ENABELD is defined and TLS_ENABELD|bool) %} | ||
tls: | ||
- hosts: | ||
- {{ DOMAIN }} | ||
{% if CLUSTER_ISSUER is defined %} | ||
secretName: {{ DOMAIN }}-tls | ||
{% endif %} | ||
{% endif %} | ||
rules: | ||
- host: {{ DOMAIN }} | ||
http: | ||
paths: | ||
- path: /tldraw-server | ||
backend: | ||
service: | ||
name: tldraw-server-svc | ||
port: | ||
number: 3345 | ||
pathType: Prefix |
22 changes: 22 additions & 0 deletions
22
ansible/roles/schulcloud-server-core/templates/tldraw-server-svc.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: tldraw-server-svc | ||
namespace: {{ NAMESPACE }} | ||
labels: | ||
app: tldraw-server | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
# port for WebSocket connection | ||
- port: 3345 | ||
targetPort: 3345 | ||
protocol: TCP | ||
name: tldraw-ws | ||
# port for http managing drawing data | ||
- port: 3349 | ||
targetPort: 3349 | ||
protocol: TCP | ||
name: tldraw-http | ||
selector: | ||
app: tldraw-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* istanbul ignore file */ | ||
/* eslint-disable no-console */ | ||
import { NestFactory } from '@nestjs/core'; | ||
import { install as sourceMapInstall } from 'source-map-support'; | ||
import { TldrawModule, TldrawWsModule } from '@modules/tldraw'; | ||
import { LegacyLogger, Logger } from '@src/core/logger'; | ||
import * as WebSocket from 'ws'; | ||
import { WsAdapter } from '@nestjs/platform-ws'; | ||
import { enableOpenApiDocs } from '@shared/controller/swagger'; | ||
import { AppStartLoggable } from '@src/apps/helpers/app-start-loggable'; | ||
import { ExpressAdapter } from '@nestjs/platform-express'; | ||
import express from 'express'; | ||
|
||
async function bootstrap() { | ||
sourceMapInstall(); | ||
|
||
const nestExpress = express(); | ||
const nestExpressAdapter = new ExpressAdapter(nestExpress); | ||
const nestApp = await NestFactory.create(TldrawModule, nestExpressAdapter); | ||
nestApp.useLogger(await nestApp.resolve(LegacyLogger)); | ||
nestApp.enableCors(); | ||
|
||
const nestAppWS = await NestFactory.create(TldrawWsModule); | ||
const wss = new WebSocket.Server({ noServer: true }); | ||
nestAppWS.useWebSocketAdapter(new WsAdapter(wss)); | ||
nestAppWS.enableCors(); | ||
enableOpenApiDocs(nestAppWS, 'docs'); | ||
const logger = await nestAppWS.resolve(Logger); | ||
|
||
await nestAppWS.init(); | ||
await nestApp.init(); | ||
|
||
// mount instances | ||
const rootExpress = express(); | ||
|
||
const port = 3349; | ||
const basePath = '/api/v3'; | ||
|
||
// exposed alias mounts | ||
rootExpress.use(basePath, nestExpress); | ||
rootExpress.listen(port); | ||
|
||
logger.info( | ||
new AppStartLoggable({ | ||
appName: 'Tldraw server app', | ||
}) | ||
); | ||
} | ||
|
||
void bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
apps/server/src/modules/board/controller/dto/element/drawing-element.response.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { ContentElementType } from '@shared/domain'; | ||
import { TimestampsResponse } from '../timestamps.response'; | ||
|
||
export class DrawingElementContent { | ||
constructor({ description }: DrawingElementContent) { | ||
this.description = description; | ||
} | ||
|
||
@ApiProperty() | ||
description: string; | ||
} | ||
|
||
export class DrawingElementResponse { | ||
constructor({ id, content, timestamps, type }: DrawingElementResponse) { | ||
this.id = id; | ||
this.timestamps = timestamps; | ||
this.type = type; | ||
this.content = content; | ||
} | ||
|
||
@ApiProperty({ pattern: '[a-f0-9]{24}' }) | ||
id: string; | ||
|
||
@ApiProperty({ enum: ContentElementType, enumName: 'ContentElementType' }) | ||
type: ContentElementType.DRAWING; | ||
|
||
@ApiProperty() | ||
timestamps: TimestampsResponse; | ||
|
||
@ApiProperty() | ||
content: DrawingElementContent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.