From c10d193615a8bf565ccbf1c048b5962084ea5120 Mon Sep 17 00:00:00 2001 From: "https://blog.iamtsm.cn" <1905333456@qq.com> Date: Thu, 10 Aug 2023 18:31:43 +0800 Subject: [PATCH] feat: docker suppose coturn image feat: push to dockerhub shell update fix: docker-compose.yml bugs --- .dockerignore | 7 +++ bin/auto-publish-image-to-hub.sh | 48 +++++++------------ bin/auto-pull-and-start-docker.sh | 31 ++++++++++-- docker-compose.yml | 23 +++++++-- docker/coturn/Dockerfile | 1 + docker/coturn/coturn.env | 6 ++- docker/coturn/turnserver-with-fixed-user.conf | 4 +- .../coturn/turnserver-with-secret-user.conf | 4 +- docker/docker-compose-build-code.yml | 19 ++++++++ svr/conf/cfg.json | 2 +- tlrtcfile.env | 10 ++-- 11 files changed, 107 insertions(+), 48 deletions(-) create mode 100644 .dockerignore create mode 100644 docker/coturn/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..26820f3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git + +svr/node_modules/ + +client/packages/rtc-web/ + +docker/mysql/data/ \ No newline at end of file diff --git a/bin/auto-publish-image-to-hub.sh b/bin/auto-publish-image-to-hub.sh index c419bd9..53b6a4c 100755 --- a/bin/auto-publish-image-to-hub.sh +++ b/bin/auto-publish-image-to-hub.sh @@ -2,53 +2,41 @@ ######################### # 一键推送dockerhub的脚本 # @auther: iamtsm -# @version: v1.0.0 +# @version: v1.1.0 ######################### ######################################## start ###################################### -build_version=latest -hub_version=v10.3.4 +latest_version=latest ######################################## build ###################################### ## build by docker-compose-build-code.yml docker-compose -f ../docker/docker-compose-build-code.yml build ######################################## tag ######################################## -# tag hub version -docker tag docker-api:$build_version iamtsm/tl-rtc-file-api:$hub_version -docker tag docker-socket:$build_version iamtsm/tl-rtc-file-socket:$hub_version -docker tag docker-mysql:$build_version iamtsm/tl-rtc-file-mysql:$hub_version - # tag latest version -docker tag docker-api:$build_version iamtsm/tl-rtc-file-api:$build_version -docker tag docker-socket:$build_version iamtsm/tl-rtc-file-socket:$build_version -docker tag docker-mysql:$build_version iamtsm/tl-rtc-file-mysql:$build_version +docker tag docker-api:$latest_version iamtsm/tl-rtc-file-api:$latest_version +docker tag docker-socket:$latest_version iamtsm/tl-rtc-file-socket:$latest_version +docker tag docker-mysql:$latest_version iamtsm/tl-rtc-file-mysql:$latest_version +docker tag docker-coturn:$latest_version iamtsm/tl-rtc-file-coturn:$latest_version ######################################## push ####################################### -# push hub version -docker push iamtsm/tl-rtc-file-api:$hub_version -docker push iamtsm/tl-rtc-file-socket:$hub_version -docker push iamtsm/tl-rtc-file-mysql:$hub_version - # push latest version -docker push iamtsm/tl-rtc-file-api:$build_version -docker push iamtsm/tl-rtc-file-socket:$build_version -docker push iamtsm/tl-rtc-file-mysql:$build_version +docker push iamtsm/tl-rtc-file-api:$latest_version +docker push iamtsm/tl-rtc-file-socket:$latest_version +docker push iamtsm/tl-rtc-file-mysql:$latest_version +docker push iamtsm/tl-rtc-file-coturn:$latest_version ######################################## del ######################################## ## del build version -docker rmi docker-api:$build_version -docker rmi docker-socket:$build_version -docker rmi docker-mysql:$build_version +docker rmi docker-api:$latest_version +docker rmi docker-socket:$latest_version +docker rmi docker-mysql:$latest_version +docker rmi docker-coturn:$latest_version # # del tag build version -docker rmi iamtsm/tl-rtc-file-api:$build_version -docker rmi iamtsm/tl-rtc-file-socket:$build_version -docker rmi iamtsm/tl-rtc-file-mysql:$build_version - -# del tag hub version -docker rmi iamtsm/tl-rtc-file-api:$hub_version -docker rmi iamtsm/tl-rtc-file-socket:$hub_version -docker rmi iamtsm/tl-rtc-file-mysql:$hub_version +docker rmi iamtsm/tl-rtc-file-api:$latest_version +docker rmi iamtsm/tl-rtc-file-socket:$latest_version +docker rmi iamtsm/tl-rtc-file-mysql:$latest_version +docker rmi iamtsm/tl-rtc-file-coturn:$latest_version ######################################## done ####################################### diff --git a/bin/auto-pull-and-start-docker.sh b/bin/auto-pull-and-start-docker.sh index 9550886..104c7f9 100755 --- a/bin/auto-pull-and-start-docker.sh +++ b/bin/auto-pull-and-start-docker.sh @@ -2,7 +2,7 @@ ######################### # 提供一键部署docker的脚本 # @auther: iamtsm -# @version: v1.0.0 +# @version: v1.1.0 ######################### # 检查Docker是否启动 @@ -38,25 +38,33 @@ export tl_rtc_file_db_open=true docker pull iamtsm/tl-rtc-file-api docker pull iamtsm/tl-rtc-file-socket docker pull iamtsm/tl-rtc-file-mysql +docker pull iamtsm/tl-rtc-file-coturn if docker images | grep -q "iamtsm/tl-rtc-file-api"; then echo "======> check image iamtsm/tl-rtc-file-api exists ok..." else - echo "======> Image $image_name does not exist. Exiting." + echo "======> Image iamtsm/tl-rtc-file-api does not exist. Exiting." exit 1 fi if docker images | grep -q "iamtsm/tl-rtc-file-socket"; then echo "======> check image iamtsm/tl-rtc-file-socket exists ok..." else - echo "======> Image $image_name does not exist. Exiting." + echo "======> Image iamtsm/tl-rtc-file-socket does not exist. Exiting." exit 1 fi if docker images | grep -q "iamtsm/tl-rtc-file-mysql"; then echo "======> check image iamtsm/tl-rtc-file-mysql exists ok..." else - echo "Image $image_name does not exist. Exiting." + echo "Image iamtsm/tl-rtc-file-mysql does not exist. Exiting." + exit 1 +fi + +if docker images | grep -q "iamtsm/tl-rtc-file-coturn"; then + echo "======> check image iamtsm/tl-rtc-file-coturn exists ok..." +else + echo "Image iamtsm/tl-rtc-file-coturn does not exist. Exiting." exit 1 fi @@ -70,9 +78,22 @@ docker run \ -e MYSQL_DATABASE=webchat \ -e MYSQL_USER=tlrtcfile \ -e MYSQL_PASSWORD=tlrtcfile \ + -v ./../docker/mysql/data/mysql.env:/tlrtcfile/docker/mysql/mysql.env \ + -v ./../docker/mysql/data/db:/var/lib/mysql \ + -v ./../docker/mysql/data/my.cnf:/etc/mysql/conf.d/my.cnf \ + -v ./../docker/mysql/data/log:/var/log/mysql \ + -v ./../docker/mysql/data/init.sql:/docker-entrypoint-initdb.d/init.sql \ --restart=always \ -d iamtsm/tl-rtc-file-mysql +# 启动coturn容器 +docker run \ + --name=coturn \ + -p 3478:3478/udp \ + -p 3478:3478/tcp \ + -v ./../docker/coturn/turnserver-with-secret-user.conf:/etc/coturn/turnserver.conf \ + -d iamtsm/tl-rtc-file-coturn + # 启动api容器 docker run \ --name=api \ @@ -111,6 +132,7 @@ docker run \ -e tl_rtc_file_notify_open \ -e tl_rtc_file_notify_qiwei_normal \ -e tl_rtc_file_notify_qiwei_error \ + -v ../tlrtcfile.env:/tlrtcfile/tlrtcfile.env \ --link mysql \ -d iamtsm/tl-rtc-file-api tlapi @@ -152,5 +174,6 @@ docker run \ -e tl_rtc_file_notify_open \ -e tl_rtc_file_notify_qiwei_normal \ -e tl_rtc_file_notify_qiwei_error \ + -v ../tlrtcfile.env:/tlrtcfile/tlrtcfile.env \ --link mysql \ -d iamtsm/tl-rtc-file-socket tlsocket \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 0a957cf..a95806c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,6 +21,7 @@ services: - mysql depends_on: - mysql + - coturn volumes: - ./tlrtcfile.env:/tlrtcfile/tlrtcfile.env @@ -32,7 +33,7 @@ services: env_file: - ./tlrtcfile.env environment: - - tl_rtc_file_env_mode=http + - tl_rtc_file_env_mode=https - tl_rtc_file_db_open=true command: - tlapi @@ -42,6 +43,7 @@ services: - mysql depends_on: - mysql + - coturn volumes: - ./tlrtcfile.env:/tlrtcfile/tlrtcfile.env @@ -63,11 +65,12 @@ services: - mysql depends_on: - mysql + - coturn volumes: - ./tlrtcfile.env:/tlrtcfile/tlrtcfile.env #https模式启动socket服务 - socket-htts: + socket-https: profiles: ['https'] container_name: socket image: iamtsm/tl-rtc-file-socket @@ -84,6 +87,7 @@ services: - mysql depends_on: - mysql + - coturn volumes: - ./tlrtcfile.env:/tlrtcfile/tlrtcfile.env @@ -102,4 +106,17 @@ services: - ./docker/mysql/data/db:/var/lib/mysql - ./docker/mysql/data/my.cnf:/etc/mysql/conf.d/my.cnf - ./docker/mysql/data/log:/var/log/mysql - - ./docker/mysql/data/init.sql:/docker-entrypoint-initdb.d/init.sql \ No newline at end of file + - ./docker/mysql/data/init.sql:/docker-entrypoint-initdb.d/init.sql + + #coturn服务 + coturn: + profiles: ['http','https'] + container_name: coturn + image: iamtsm/tl-rtc-file-coturn + env_file: + - ./docker/coturn/coturn.env + ports: + - "3478:3478/udp" + - "3478:3478/tcp" + volumes: + - ./docker/coturn/turnserver-with-secret-user.conf:/etc/turnserver.conf \ No newline at end of file diff --git a/docker/coturn/Dockerfile b/docker/coturn/Dockerfile new file mode 100644 index 0000000..509a870 --- /dev/null +++ b/docker/coturn/Dockerfile @@ -0,0 +1 @@ +FROM coturn/coturn \ No newline at end of file diff --git a/docker/coturn/coturn.env b/docker/coturn/coturn.env index a6b58bf..05fbd8e 100644 --- a/docker/coturn/coturn.env +++ b/docker/coturn/coturn.env @@ -1 +1,5 @@ -#coturn env feature use \ No newline at end of file +## coturn 配置 + +#自动检测外网ip和中转ip +# DETECT_EXTERNAL_IP=yes +# DETECT_RELAY_IP=yes \ No newline at end of file diff --git a/docker/coturn/turnserver-with-fixed-user.conf b/docker/coturn/turnserver-with-fixed-user.conf index ad909a4..48d9c02 100644 --- a/docker/coturn/turnserver-with-fixed-user.conf +++ b/docker/coturn/turnserver-with-fixed-user.conf @@ -13,8 +13,8 @@ min-port=49152 min-port=55000 #cli密码 cli-password=qwerty -#后台运行 -daemon +#后台运行-默认关闭 docker运行时需关闭, 自行部署时,可以开启 +# daemon #会话指纹 fingerprint #中等详细日志 diff --git a/docker/coturn/turnserver-with-secret-user.conf b/docker/coturn/turnserver-with-secret-user.conf index bf24a34..634221f 100644 --- a/docker/coturn/turnserver-with-secret-user.conf +++ b/docker/coturn/turnserver-with-secret-user.conf @@ -13,8 +13,8 @@ min-port=49152 min-port=55000 #cli密码 cli-password=qwerty -#后台运行 -daemon +#后台运行-默认关闭 docker运行时需关闭, 自行部署时,可以开启 +# daemon #会话指纹 fingerprint #中等详细日志 diff --git a/docker/docker-compose-build-code.yml b/docker/docker-compose-build-code.yml index a39e0f1..251c6c4 100644 --- a/docker/docker-compose-build-code.yml +++ b/docker/docker-compose-build-code.yml @@ -4,6 +4,7 @@ version: '3' services: + #api服务 api: container_name: api build: @@ -19,9 +20,11 @@ services: - mysql depends_on: - mysql + - coturn volumes: - ../tlrtcfile.env:/tlrtcfile/tlrtcfile.env + #socket服务 socket: container_name: socket build: @@ -37,9 +40,11 @@ services: - mysql depends_on: - mysql + - coturn volumes: - ../tlrtcfile.env:/tlrtcfile/tlrtcfile.env + #mysql服务 mysql: container_name: mysql restart: always @@ -56,3 +61,17 @@ services: - ./mysql/data/my.cnf:/etc/mysql/conf.d/my.cnf - ./mysql/data/log:/var/log/mysql - ./mysql/data/init.sql:/docker-entrypoint-initdb.d/init.sql + + #coturn服务 + coturn: + container_name: coturn + env_file: + - ./coturn/coturn.env + build: + context: ./coturn/ + dockerfile: ./Dockerfile + ports: + - "3478:3478/udp" + - "3478:3478/tcp" + volumes: + - ./coturn/turnserver-with-secret-user.conf:/etc/turnserver.conf \ No newline at end of file diff --git a/svr/conf/cfg.json b/svr/conf/cfg.json index b564911..14f15e8 100644 --- a/svr/conf/cfg.json +++ b/svr/conf/cfg.json @@ -1,5 +1,5 @@ { - "version": "10.3.4", + "version": "10.3.5", "ws": { "port": "请到 http.env 或者 https.env中进行配置", "host": "请到 http.env 或者 https.env中进行配置" diff --git a/tlrtcfile.env b/tlrtcfile.env index 17581f8..6ef4638 100644 --- a/tlrtcfile.env +++ b/tlrtcfile.env @@ -9,15 +9,15 @@ tl_rtc_file_ws_host=ws://127.0.0.1:8444 #-----------------以下为webrtc相关配置-----------------# ## webrtc-stun中继服务地址 -tl_rtc_file_webrtc_stun_host= +tl_rtc_file_webrtc_stun_host=stun:127.0.0.1:3478 ## webrtc-turn中继服务地址 -tl_rtc_file_webrtc_turn_host= +tl_rtc_file_webrtc_turn_host=turn:127.0.0.1:3478?transport=udp ## webrtc中继服务用户名 -tl_rtc_file_webrtc_turn_username= +tl_rtc_file_webrtc_turn_username=tlrtcfile ## webrtc中继服务密码 -tl_rtc_file_webrtc_turn_credential= +tl_rtc_file_webrtc_turn_credential=tlrtcfile ## webrtc中继服务Secret -tl_rtc_file_webrtc_turn_secret= +tl_rtc_file_webrtc_turn_secret=tlrtcfile ## webrtc中继服务帐号过期时间 (毫秒) tl_rtc_file_webrtc_turn_expire=86400000