Skip to content

Commit

Permalink
Added openvidu call v3
Browse files Browse the repository at this point in the history
  • Loading branch information
CSantosM committed Jun 26, 2024
1 parent 7d7a65a commit bef5b33
Show file tree
Hide file tree
Showing 127 changed files with 27,520 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Build OpenVidu Call for production
FROM --platform=linux/amd64 node:20 as openvidu-call-build

WORKDIR /openvidu-call

ARG BASE_HREF=/

COPY . .

# Build OpenVidu Call frontend
RUN cd openvidu-call-front && npm install && \
npm run prod:build ${BASE_HREF} && \
cd ../ && rm -rf openvidu-call-front

FROM node:20-alpine3.19

WORKDIR /opt/openvidu-call

COPY --from=openvidu-call-build /openvidu-call/openvidu-call-back .

RUN npm install -g npm

# Install backend dependencies and build it for production
RUN npm install && \
npm run build

# Entrypoint
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN apk add --no-cache curl && \
chmod +x /usr/local/bin/entrypoint.sh && \
chown -R node:node /opt/openvidu-call

USER node

EXPOSE $SERVER_PORT

CMD ["/usr/local/bin/entrypoint.sh"]
9 changes: 9 additions & 0 deletions docker/create_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -x

IMAGE=${1:-?echo "Error: You need to specify an image name as first argument"?}
if [[ -n $IMAGE ]]; then
cd ..
export BUILDKIT_PROGRESS=plain && docker build --pull --no-cache --rm=true -f docker/Dockerfile -t "$IMAGE" --build-arg BASE_HREF=/ .
else
echo "Error: You need to specify a version as first argument"
fi
9 changes: 9 additions & 0 deletions docker/create_image_demos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -x

IMAGE="${1:-?echo "Error: You need to specify an image name as first argument"?}"
if [[ -n $VERSION ]]; then
cd ..
docker build --pull --no-cache --rm=true -f docker/Dockerfile -t "$IMAGE"-demos --build-arg BASE_HREF=/openvidu-call/ .
else
echo "Error: You need to specify a version as first argument"
fi
52 changes: 52 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh

# Function to handle termination signals
terminate_process() {
echo "Terminating Node.js process..."
pkill -TERM node
}

# Trap termination signals
trap terminate_process TERM INT

if [ -z "${LIVEKIT_URL}" ]; then
echo "LIVEKIT_URL is required"
echo "example: docker run -e LIVEKIT_URL=https://livekit-server:7880 -e LIVEKIT_API_KEY=api_key -e LIVEKIT_API_SECRET=api_secret -p 5000:5000 openvidu-call"
exit 1
fi
if [ -z "${LIVEKIT_API_KEY}" ]; then
echo "LIVEKIT_API_KEY is required"
echo "example: docker run -e LIVEKIT_URL=https://livekit-server:7880 -e LIVEKIT_API_KEY=api_key -e LIVEKIT_API_SECRET=api_secret -p 5000:5000 openvidu-call"
exit 1
fi
if [ -z "${LIVEKIT_API_SECRET}" ]; then
echo "LIVEKIT_API_SECRET is required"
echo "example: docker run -e LIVEKIT_URL=https://livekit-server:7880 -e LIVEKIT_API_KEY=api_key -e LIVEKIT_API_SECRET=api_secret -p 5000:5000 openvidu-call"
exit 1
fi

# openvidu-call configuration
cat>/opt/openvidu-call/.env<<EOF
SERVER_PORT=${SERVER_PORT}
LIVEKIT_URL=${LIVEKIT_URL}
LIVEKIT_URL_PRIVATE=${LIVEKIT_URL_PRIVATE}
LIVEKIT_API_KEY=${LIVEKIT_API_KEY}
LIVEKIT_API_SECRET=${LIVEKIT_API_SECRET}
USE_HTTPS=${USE_HTTPS}
CALL_ADMIN_SECRET=${CALL_ADMIN_SECRET}
CALL_PRIVATE_ACCESS=${CALL_PRIVATE_ACCESS}
CALL_USER=${CALL_USER}
CALL_SECRET=${CALL_SECRET}
CALL_RECORDING=${CALL_RECORDING}
CALL_BROADCAST=${CALL_BROADCAST}
CALL_RECORDING_PATH=${CALL_RECORDING_PATH}
EOF

cd /opt/openvidu-call
node dist/server.js &

# Save the PID of the Node.js process
node_pid=$!

# Wait for the Node.js process to finish
wait $node_pid
45 changes: 45 additions & 0 deletions openvidu-call-back/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/no-inferrable-types": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"lines-between-class-members": [
"warn",
{
"enforce": [
{
"blankLine": "always",
"prev": "method",
"next": "method"
}
]
}
],
"padding-line-between-statements": [
"warn",
{
"blankLine": "always",
"prev": "*",
"next": ["if", "for", "while", "switch"]
},
{
"blankLine": "always",
"prev": ["if", "for", "while", "switch"],
"next": "*"
},
{ "blankLine": "always", "prev": "*", "next": "block-like" },
{ "blankLine": "always", "prev": "block-like", "next": "*" }
]
}
}
10 changes: 10 additions & 0 deletions openvidu-call-back/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"singleQuote": true,
"printWidth": 120,
"trailingComma": "none",
"semi": true,
"bracketSpacing": true,
"useTabs": true,
"jsxSingleQuote": true,
"tabWidth": 4
}
16 changes: 16 additions & 0 deletions openvidu-call-back/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch OpenVidu Call Back",
"program": "${workspaceFolder}/src/server.ts",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}
Loading

0 comments on commit bef5b33

Please sign in to comment.