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

refactor: migrate mediasoup WebRTC server from JavaScript to TypeScript #29

Merged
merged 14 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 8 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
25 changes: 25 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
123 changes: 123 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Continuous Integration

on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, labeled]
push:
branches: [main]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout message-pickup-repository
gabrielmatau79 marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/checkout@v4

- name: Setup node v22
uses: actions/setup-node@v4
with:
node-version: 22

- name: Install dependencies
run: |
yarn install

- name: Check Format
run: |
yarn format

- name: Check Types
run: |
yarn check-types

- name: Unit tests
run: |
yarn test

- name: E2E tests
run: |
yarn test:e2e

release-please:
runs-on: ubuntu-latest
needs: [build]
outputs:
releases_created: ${{ steps.release-please.outputs.releases_created }}
paths_released: ${{ steps.release-please.outputs.paths_released }}
steps:
- uses: googleapis/release-please-action@v4
id: release-please
with:
path: ./packages
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
token: ${{ secrets.GITHUB_TOKEN }}

- name: Print release outputs for debugging
continue-on-error: true
run: |
echo "Release outputs:"
echo ${{ toJson(steps.release-please.outputs) }}

# Initiate release process if release was created
release-client:
if: contains(needs.release-please.outputs.paths_released, 'packages/client')
runs-on: ubuntu-latest
needs: [release-please]
steps:
- name: Checkout message-pickup-repository
uses: actions/checkout@v4
- name: Setup node v20
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org/'
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts

- name: Release to NPM
run: |
cd packages/client
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

release-server:
if: contains(needs.release-please.outputs.paths_released, 'packages/server')
runs-on: ubuntu-latest
needs: [release-please]
env:
DH_USERNAME: ${{secrets.DOCKER_HUB_LOGIN}}
DH_TOKEN: ${{secrets.DOCKER_HUB_PWD}}
IMAGE_NAME: 'message-pickup-repository'
IMAGE_TAG: ${{ github.ref == 'refs/heads/main' && 'dev' || github.ref }}
steps:
- name: Checkout message-pickup-repository
uses: actions/checkout@v4
- name: Setup node v20
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org/'
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts

- name: Log in to Docker Hub
run: |
echo "$DH_TOKEN" | docker login -u "$DH_USERNAME" --password-stdin

- name: Build Docker image
run: |
cp yarn.lock packages/server
cd packages/server
docker build -f Dockerfile -t $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG .

- name: Push to DockerHub
run: docker push $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG
38 changes: 36 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
node_modules
certs
# compiled output
/dist
/node_modules
/certs

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 120,
"semi": false,
"singleQuote": true
}
52 changes: 32 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
# Stage 0, build the Webrtc Server
FROM node:18-slim

# Install DEB dependencies and others.
RUN \
set -x \
&& apt-get update \
&& apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*

WORKDIR /server

COPY package.json .
COPY package-lock.json .
RUN npm install
COPY server.js .
COPY config.js .
COPY lib lib
ADD start.sh .

CMD ["sh", "/server/start.sh"]
# Stage 0, build the Webrtc Server
FROM node:22-slim as builder

# Install DEB dependencies and others.
RUN \
set -x \
&& apt-get update \
&& apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*

gabrielmatau79 marked this conversation as resolved.
Show resolved Hide resolved
# MPR Setup
WORKDIR /app

# Copy package.json and yarn.lock first to leverage Docker layer caching
COPY package.json package.json
COPY yarn.lock yarn.lock

# Run yarn install after copying only dependency files
RUN yarn install

# Copy other dependencies and configuration files
COPY ./src ./src
COPY tsconfig.json tsconfig.json
COPY tsconfig.build.json tsconfig.build.json

# Build the project
RUN yarn build

# Define a volume for external configuration files
VOLUME /app/dist/config

# Command to start the application when the container runs
CMD ["yarn", "start"]

Loading
Loading