Skip to content

Commit

Permalink
feat: update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
yuminn-k committed Nov 15, 2024
1 parent f85c6de commit 67a5d65
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
17 changes: 5 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,14 @@ FROM node:18
# Set the working directory inside the container
WORKDIR /app

# Install required dependencies for mediasoup and SSL
# Install required dependencies for mediasoup
RUN apt-get update && \
apt-get install -y \
python3 \
python3-pip \
build-essential \
python3-dev \
pkg-config \
openssl

# Create SSL directory
RUN mkdir -p /app/config/ssl

# Generate self-signed certificate
RUN openssl req -x509 -newkey rsa:2048 -keyout /app/config/ssl/key.pem -out /app/config/ssl/crt.pem -days 365 -nodes -subj "/CN=localhost"

# Set proper permissions for SSL files
RUN chmod 600 /app/config/ssl/key.pem /app/config/ssl/crt.pem
pkg-config

# Copy package files
COPY package*.json ./
Expand All @@ -32,6 +22,9 @@ RUN npm install
# Copy the rest of the application code
COPY . .

# Add healthcheck endpoint for ALB
COPY healthcheck.js ./

# Expose the main server port
EXPOSE 8000

Expand Down
3 changes: 3 additions & 0 deletions healthcheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
app.get("/healthcheck", (req, res) => {
res.status(200).send("OK");
});
19 changes: 11 additions & 8 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ const mediasoup = require("mediasoup");
const fs = require("fs");

const PORT = 8000;
const option = {
key: fs.readFileSync("./config/ssl/key.pem", "utf-8"),
cert: fs.readFileSync("./config/ssl/crt.pem", "utf-8"),
};
const server = require("https").createServer(option, app);
const server = require("http").createServer(app);
const io = require("socket.io")(server, {
cors: {
origin: "*",
origin: [
"https://minoriedu.com",
"http://minoriedu.com",
"http://127.0.0.1:3000",
"http://127.0.0.1:3001",
],
methods: ["GET", "POST"],
credentials: true,
transports: ["websocket", "polling"],
},
allowEIO3: true,
});
const corsOptions = {
origin: "*",
Expand Down Expand Up @@ -402,8 +405,8 @@ const createWebRtcTransport = async (router) => {
const webRtcTransport_options = {
listenIps: [
{
ip: "3.39.137.182", // replace with relevant IP address
// announcedIp: "10.0.0.115",
ip: "0.0.0.0", // replace with relevant IP address
announcedIp: "minoriedu.com",
},
],
enableUdp: true,
Expand Down

0 comments on commit 67a5d65

Please sign in to comment.