mirror of
https://github.com/tl-open-source/tl-rtc-file.git
synced 2025-10-08 08:50:16 +08:00
feat: 规范docker的部署方式
This commit is contained in:
17
Dockerfile
17
Dockerfile
@@ -1,14 +1,7 @@
|
||||
FROM node:14-alpine
|
||||
FROM node:lts-alpine
|
||||
COPY svr /app/svr
|
||||
WORKDIR /app/svr
|
||||
RUN npm install --registry=https://registry.npmmirror.com && npm run build:pro
|
||||
|
||||
WORKDIR /home/tlrtcfile
|
||||
|
||||
ADD . .
|
||||
|
||||
RUN npm conf set registry https://registry.npm.taobao.org; \
|
||||
npm install -g pm2; \
|
||||
cd /home/tlrtcfile/svr; \
|
||||
npm install;
|
||||
|
||||
EXPOSE 9092 8444
|
||||
|
||||
CMD ["/bin/sh", "docker-entrypoint.sh"]
|
||||
ENTRYPOINT ["node"]
|
||||
|
18
docker-compose.yml
Normal file
18
docker-compose.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
version: '3'
|
||||
services:
|
||||
api:
|
||||
env_file:
|
||||
- local.env
|
||||
build: .
|
||||
ports:
|
||||
- 9092:9092
|
||||
links:
|
||||
- socket
|
||||
command: localapi
|
||||
socket:
|
||||
env_file:
|
||||
- local.env
|
||||
build: .
|
||||
ports:
|
||||
- 8444:8444
|
||||
command: localsocket
|
@@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /home/tlrtcfile/svr
|
||||
|
||||
npm i
|
||||
|
||||
pm2 start npm --name=tlapi -- run lapi
|
||||
|
||||
pm2 start npm --name=tlsocket -- run lsocket
|
||||
|
||||
npm run build:pro
|
||||
|
||||
sleep 2
|
||||
|
||||
pm2 logs
|
||||
|
||||
|
||||
|
6
local.env
Normal file
6
local.env
Normal file
@@ -0,0 +1,6 @@
|
||||
ENV_MODE=local
|
||||
WEBRTC_STUN_HOST=stun:stun.xten.com
|
||||
WEBRTC_TURN_HOST=turn:global.turn.twilio.com:3478?transport=udp
|
||||
WEBRTC_TURN_USERNAME=dc2d2894d5a9023620c467b0e71cfa6a35457e6679785ed6ae9856fe5bdfa269
|
||||
WEBRTC_TURN_CREDENTIAL=tE2DajzSJwnsSbc123
|
||||
WS_HOST=ws://127.0.0.1:8444
|
23
svr/conf/env_config.js
Normal file
23
svr/conf/env_config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const inject_env_config=(conf)=>{
|
||||
Object.keys(process.env).filter(key=>/^(WS(S)?_|API_|WEBRTC_).+/.test(key)).map(key=>{
|
||||
let data=process.env[key]
|
||||
if(key.endsWith('_PORT')){
|
||||
data=parseInt(data)
|
||||
}
|
||||
let curr=conf;
|
||||
const paths=key.split('_').map(p=>p.toLowerCase())
|
||||
const last=paths.pop()
|
||||
for (const path of paths){
|
||||
curr=curr[path]
|
||||
}
|
||||
if(curr){
|
||||
console.log(`config ${paths.join('.')}.${last} to ${data}`);
|
||||
curr[last]=data
|
||||
}
|
||||
|
||||
})
|
||||
return conf
|
||||
}
|
||||
module.exports = {
|
||||
inject_env_config
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
const express = require("express");
|
||||
const conf = require("./conf/cfg.json");
|
||||
const { inject_env_config } = require("./conf/env_config");
|
||||
const conf = inject_env_config(require("./conf/cfg.json"));
|
||||
const fileApiRouters = require("./src/controller/router")();
|
||||
const db = require("./src/tables/db"); //db
|
||||
const utils = require("./src/utils/utils");
|
||||
|
@@ -1,7 +1,8 @@
|
||||
const http = require('http'); // http
|
||||
const socketIO = require('socket.io'); //socket
|
||||
const db = require("./src/tables/db"); //db
|
||||
const conf = require("./conf/cfg.json"); //conf
|
||||
const { inject_env_config } = require("./conf/env_config");
|
||||
const conf = inject_env_config(require("./conf/cfg.json")); //conf
|
||||
const socket = require("./src/socket/index") //socket handler
|
||||
const utils = require("./src/utils/utils");
|
||||
|
||||
|
Reference in New Issue
Block a user