Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Unstaged Update #89

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
**/node_modules
**/dist
.env.example
.git
dist/
node_modules/
Dockerfile
16 changes: 3 additions & 13 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,14 @@ PORTALS_WS_URL=
# This should the same secure key in @cryb/portals/.env under 'PORTAL_KEY'
PORTALS_KEY=

## These arguments are ignored if you have Janus enabled in @cryb/portals
# The URL of @cryb/aperture streaming that ffmpeg should stream to. This should be :9000 on @cryb/aperture.
STREAMING_URL=
# This should the same secure key in @cryb/aperture/.env under 'STREAMING_KEY'. Not needed in Janus.
STREAMING_KEY=portal-streaming-key

# The Display services like Chromium and ffmpeg/gstreamer will use
DISPLAY=:100
# The width of the video stream in px
VIDEO_WIDTH=1280
VIDEO_WIDTH=1366
# The height of the video stream in px
VIDEO_HEIGHT=720
VIDEO_HEIGHT=768
# The bitrate of the video stream in bits
VIDEO_BITRATE=1200000
VIDEO_BITRATE=4200000
# The Frames Per Second of the video stream (the lower it is, the higher performance is)
VIDEO_FPS=30
# Switch to false if you want to disable audio support (could result in better performance)
AUDIO_ENABLED=true
# The bitrate of the audio stream in bits
AUDIO_BITRATE=128000

Expand Down
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

35 changes: 0 additions & 35 deletions .eslintrc.json

This file was deleted.

52 changes: 25 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
FROM node:lts-buster
# Builder image, we get the dependencies and stuff here
FROM node:22-bookworm AS builder
WORKDIR /build
COPY logo.txt package.json pnpm-lock.yaml tsconfig.json /build/
RUN npm i -g pnpm && pnpm i
COPY ./src /build/src
RUN pnpm build && pnpm pack

FROM node:22-bookworm
WORKDIR /home/glados/.internal

# Install Chromium, audio and other misc packages, cleanup, create Chromium policies folders, workarounds
RUN apt-get update && apt-get -y dist-upgrade && \
apt-get --no-install-recommends -y install \
psmisc \
rsync \
dbus \
dbus-x11 \
xvfb \
x11-xserver-utils \
mesa-utils \
xdotool \
openbox \
fonts-opensymbol \
Expand All @@ -22,23 +35,12 @@ RUN apt-get update && apt-get -y dist-upgrade && \
fonts-noto-color-emoji \
fonts-noto \
fonts-nanum \
fonts-recommended \
pulseaudio \
x11-session-utils \
libgstreamer1.0-0 \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-doc \
gstreamer1.0-tools \
gstreamer1.0-x \
gstreamer1.0-alsa \
gstreamer1.0-gl \
gstreamer1.0-gtk3 \
gstreamer1.0-qt5 \
gstreamer1.0-pulseaudio \
ffmpeg \
chromium \
sudo \
grep \
Expand All @@ -50,28 +52,24 @@ RUN apt-get update && apt-get -y dist-upgrade && \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
&& mkdir -p /var/run/dbus \
&& mkdir -p /etc/chromium/policies/managed \
&& mkdir /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix && chown root /tmp/.X11-unix

# Add normal user
RUN useradd glados --shell /bin/bash --create-home \
&& mkdir /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix && chown root /tmp/.X11-unix \
&& useradd glados --shell /bin/bash --create-home \
&& usermod -a -G audio glados

# Copy information
WORKDIR /home/glados/.internal
COPY . .

# Chromium Policies & Preferences
COPY ./configs/chromium_policy.json /etc/chromium/policies/managed/policies.json
COPY ./configs/master_preferences.json /etc/chromium/master_preferences
# Pulseaudio Configuration
COPY ./configs/pulse_config.pa /tmp/pulse_config.pa
COPY ./configs/pulse_config.pa /etc/pulse/default.pa
# Openbox Configuration
COPY ./configs/openbox_config.xml /var/lib/openbox/openbox_config.xml

# Install deps, build then cleanup
RUN yarn install --frozen-lockfile && yarn build && yarn cache clean && rm -rf src
COPY --from=builder /build/cryb-portal-1.0.0.tgz /home/glados/.internal/

# Run first Widevine component install for Chromium
RUN sudo -u glados bash ./widevine.sh
RUN tar -xzf /home/glados/.internal/cryb-portal-1.0.0.tgz \
&& rsync -vua --delete-after /home/glados/.internal/package/ /home/glados/.internal/ \
&& chown -R glados:glados /home/glados
COPY ./start.sh ./widevine.sh ./.env* /home/glados/.internal/
RUN sudo -u glados bash /home/glados/.internal/widevine.sh

ENTRYPOINT [ "bash", "./start.sh" ]
ENTRYPOINT [ "/home/glados/.internal/start.sh" ]
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ The codebase for `@cryb/portal` is written in JavaScript, utilising TypeScript a

We ask that you follow our [code style guidelines](https://github.com/crybapp/library/blob/master/code-style/STYLE.md) when contributing to this repository.

We use TSLint in order to lint our code. Run `yarn lint` before committing any code to ensure it's clean.
We use ESLint in order to lint our code. Run `pnpm lint` before committing any code to ensure it's clean.

*Note: while we have most rules covered in our `tslint.json` config, it's good practice to familarise yourself with our code style guidelines*
*Note: while we have most rules covered in our `eslint.config.mjs` config, it's good practice to familarise yourself with our code style guidelines*

### Folder Structure

Expand All @@ -64,15 +64,15 @@ git clone https://github.com/crybapp/portal.git
The following services need to be installed for `@cryb/portal` to function:

* `@cryb/portals`
* `@cryb/aperture` or Janus WebRTC Server
* Janus WebRTC Server

We recommend that you run the following services alongside `@cryb/portal`, but it's not required.

* `@cryb/api`
* `@cryb/web`
* `@cryb/aperture` or Janus WebRTC Server
* Janus WebRTC Server

You also need to install the required dependencies by running `yarn`
You also need to install the required dependencies by running `pnpm i`

Ensure that `.env.example` is either copied and renamed to `.env`, or is simply renamed to `.env`.

Expand All @@ -82,15 +82,15 @@ In this file, you'll need some values. Documentation is available in the `.env.e

#### Background Services

Make sure `@cryb/portals` is running on port 5000 and that you have setup `@cryb/aperture` or Janus WebRTC Server.
Make sure `@cryb/portals` is running on port 5000 and that you have setup Janus WebRTC Server.

#### Starting @cryb/portal

We recommend that you use a service like [Docker](https://docker.com) to start an instance of `@cryb/portal`.

To run `@cryb/portal` in development mode on Docker, run `yarn docker:dev`.
To run `@cryb/portal` in development mode on Docker, run `pnpm run docker:dev`.

Use `yarn docker:build` to build an image for deployment in production.
Use `pnpm run docker:build` to build an image for deployment in production.

## Questions / Issues

Expand Down
2 changes: 1 addition & 1 deletion configs/chromium_policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"BookmarkBarEnabled": false,
"BrowserAddPersonEnabled": false,
"BrowserGuestModeEnabled": false,
"BrowserSignin": 1,
"BrowserSignin": 0,
"DownloadRestrictions": 2,
"EditBookmarksEnabled": false,
"EnableSyncConsent": false,
Expand Down
62 changes: 62 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import globals from 'globals'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
})

export default [{
ignores: ['dist/', 'node_modules/'],
}, ...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/stylistic'
), {

languageOptions: {
globals: {
...globals.node,
},
},

rules: {
'comma-spacing': 'error',
'comma-style': 'error',
'eol-last': ['error', 'always'],
indent: ['error', 2],
'linebreak-style': ['error', 'unix'],

'max-nested-callbacks': ['error', {
max: 4,
}],

'max-statements-per-line': ['error', {
max: 2,
}],

'no-multi-spaces': 'error',

'no-multiple-empty-lines': ['error', {
max: 2,
maxEOF: 1,
maxBOF: 0,
}],

'no-trailing-spaces': ['error'],
'no-var': 'error',
'object-curly-spacing': ['error', 'always'],
'prefer-const': 'error',
quotes: ['error', 'single'],
semi: ['error', 'never'],
'space-before-blocks': 'error',
'spaced-comment': 'error',
yoda: 'error',
},
}]
39 changes: 21 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"version": "1.0.0",
"description": "The service deployed on VM instances to launch Chromium & more",
"main": "dist/index.js",
"type": "module",
"repository": "https://github.com/crybapp/portal.git",
"author": "JeDaYoshi <[email protected]>",
"license": "MIT",
"scripts": {
"build": "tsc",
"build": "ncc build src/index.ts -mso dist",
"start": "node dist",
"lint": "eslint src",
"lint:fix": "eslint --fix src",
Expand All @@ -19,23 +20,25 @@
"dist/**/*",
"logo.txt"
],
"dependencies": {
"dotenv": "^10.0.0",
"jsonwebtoken": "^8.5.1",
"keysym": "^0.0.6",
"process-exists": "^4.1.0",
"ws": "^8.2.2",
"yargs": "^17.2.1"
},
"devDependencies": {
"@types/jsonwebtoken": "^8.5.5",
"@types/keysym": "^0.0.1",
"@types/node": "^16.10.1",
"@types/ws": "^8.2.0",
"@types/yargs": "^17.0.3",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"eslint": "^7.32.0",
"typescript": "^4.4.3"
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.12.0",
"@types/eslint__js": "^8.42.3",
"@types/jsonwebtoken": "^9.0.7",
"@types/keysym": "^0.0.4",
"@types/node": "^22.7.5",
"@types/ws": "^8.5.12",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^8.9.0",
"@vercel/ncc": "^0.38.2",
"dotenv": "^16.4.5",
"eslint": "^9.12.0",
"globals": "^15.11.0",
"jsonwebtoken": "^9.0.2",
"keysym": "^0.0.6",
"process-exists": "^5.0.0",
"typescript": "^5.6.3",
"ws": "^8.18.0",
"yargs": "^17.7.2"
}
}
Loading