Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 12 additions & 1 deletion .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,28 @@ WEB_BASE_URL='' # https://livedvr.tripsdd.com
DATA_DIR=/data
# docker仓库的目录, 不建议在compose文件中引用docker仓库的绝对路径, 建议使用configs替代: https://docs.docker.com/reference/compose-file/configs/
DOCKER_DIR=/home/docker
DOCKER_COMPOSE_DIR=/home/docker-compose

## 版本号, 设为latest则使用最新版
# bus前端版本
BUS_WEB_VERSION=5.30.0
# bus前端文件复写目录, 该目录中的文件会在compose被up时被复制到bus前端目录, 通常可以复写如下文件:
# - _app.config.js: 前端配置文件
BUS_WEB_OVERRIDE_DIR=${DOCKER_COMPOSE_DIR}/bus-override
# bus的后端, gateway-web和gateway-dispatch共用一个版本号
BUS_GATEWAY_VERSION=1.21.1
BUS_GATEWAY_808_2019_VERSION=25.8.25
BUS_GATEWAY_JSATL12_VERSION=23.1.21
BUS_GATEWAY_CALCULATION_VERSION=1.17.0
# track前端版本
TRACK_WEB_VERSION=1.53.0
# track前端文件复写目录, 该目录中的文件会在compose被up时被复制到track前端目录, 通常可以复写如下文件:
# - _app.config.js: 前端配置文件
# - index-seo.html: 交给爬虫(搜索引擎/Line网页摘要等)读取的静态页面
# - favicon.ico: ico图标
# - favicon.png: png图标
# - logo.png: 大图标
TRACK_WEB_OVERRIDE_DIR=${DOCKER_COMPOSE_DIR}/track-override
TRACK_MAINTAIN_VERSION=1.45.0
TRACK_JTT808_VERSION=1.18.0

Expand Down Expand Up @@ -92,7 +103,7 @@ MAINTAIN_PORT='8080'
# - access/ras_key|ras_key.pub: 访问密钥的公私钥对
# - refresh/ras_key|ras_key.pub: 刷新密钥的公私钥对
# - ip2region.xdb: ip到区域的映射数据, 手动下载连接: https://raw.githubusercontent.com/lionsoul2014/ip2region/master/data/ip2region.xdb
MAINTAIN_TOKEN_DIR='/home/docker-compose/token'
MAINTAIN_TOKEN_DIR=${DOCKER_COMPOSE_DIR}/token

## MYSQL, 必填
MYSQL_HOST='mysql8' # mysql8 | ${SERVER_IP_INTERNAL} | ${SERVER_IP_PUBLIC}
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ git clone https://github.com/TranscodeGroup/docker.git /home/docker
- [video-storage](./examples/video-storage/compose.yaml): RTP存储
- [video-stream](./examples/video-stream/compose.yaml): RTP视频
- [track](./examples/track/compose.yaml): Tracker V2单机部署
- etc.

### 3. 配置`.env`

Expand All @@ -38,6 +39,16 @@ docker compose config > compose-stack.yaml

### 4. 下载前端文件

#### 使用Docker自动下载

在`/home/docker-compose/compose.yaml`文件中, `include`如下服务, 即可自动下载前端:

- [compose.yaml](./web-downloader/compose.yaml): 自动下载的基础配置
- [compose.track.yaml](./web-downloader/compose.track.yaml): 自动下载track的配置, 可选;
- [compose.bus.yaml](./web-downloader/compose.bus.yaml): 自动下载bus的配置, 可选;

#### 手动下载

部署distar等项目的前端:
[说明文件](projects/README.md)

Expand Down
12 changes: 11 additions & 1 deletion nginx/conf/conf.d/track.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@ server {

# 平台前端
location / {
alias /usr/share/nginx/html/track/;
root /usr/share/nginx/html/track;
index index.html index.htm;

if ($is_crawler) {
rewrite ^/(index.html)?$ /index-seo.html last;
}
}

# 平台前端, 交给爬虫读取的index文件
location = /index-seo.html {
root /usr/share/nginx/html/track;
try_files /index-seo.html /index.html =404;
}

location /track {
Expand Down
11 changes: 11 additions & 0 deletions nginx/conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ http {
'' close;
}

# 检测是否是爬虫
map $http_user_agent $is_crawler {
default 0;
# 搜索引擎
~*(Googlebot|Bingbot|Baiduspider|Slurp|DuckDuckBot|Sogou|360Spider|Yandex|Applebot) 1;
# 社交媒体
~*(facebookexternalhit|Twitterbot|LinkedInBot|Slackbot|Discordbot|Linespider|Bytespider) 1;
# 新兴AI
~*(GPTBot|ChatGPT-User|ClaudeBot|PerplexityBot|CCBot) 1;
}

# Docker Compose的默认DNS
# https://stackoverflow.com/questions/35744650/docker-network-nginx-resolver
resolver 127.0.0.11;
Expand Down
29 changes: 16 additions & 13 deletions projects/distar-beta-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,22 @@ cp -Rfv "$CONFIG_DIR"/* "$target_dir"
# 指定要处理的HTML文件
cd "$target_dir"
html_file="index.html"

# 使用sed命令进行文本替换, 网站微缩图
OLD_TITLE='中车在线'
NEW_TITLE='DiStarGPS'
OLD_DIV='数字交通云平台'
NEW_DIV='ดูแลการเดินรถของคุ'

# 使用sed命令进行文本替换
sed -i.bak "s|$OLD_TITLE|$NEW_TITLE|g" "$html_file"
sed -i.bak "s|$OLD_DIV|$NEW_DIV|g" "$html_file"
rm "$html_file".bak

echo "替换完成:$html_file 中的 '工物员' 已被替换为 'DiStarGPS ดูแลการเดินรถของคุณ'"
if [ -f "index-seo.html" ]; then
echo "index-seo.html文件已存在, 爬虫访问网站时, 它的优先级更高, 不需要替换${html_file}里面的标题&描述"
else
# 使用sed命令进行文本替换, 网站微缩图
OLD_TITLE='中车在线'
NEW_TITLE='DiStarGPS'
OLD_DIV='数字交通云平台'
NEW_DIV='ดูแลการเดินรถของคุ'

# 使用sed命令进行文本替换
sed -i.bak "s|$OLD_TITLE|$NEW_TITLE|g" "$html_file"
sed -i.bak "s|$OLD_DIV|$NEW_DIV|g" "$html_file"
rm "$html_file".bak

echo "替换完成:$html_file 中的 '工物员' 已被替换为 'DiStarGPS ดูแลการเดินรถของคุณ'"
fi

echo "解压完成,目录 -> " "$target_dir"
echo "beta路径,复制到浏览器可预览 -> " https://tripsdd.com/beta/"$target_dir"
18 changes: 18 additions & 0 deletions projects/distar/index-seo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>DiStarGPS</title>
<meta name="description" content="ดูแลการเดินรถของคุณ" />
<link rel="apple-touch-icon" href="./favicon.png" />
<link rel="shortcut icon" href="./favicon.ico" />
</head>

<body>
<h1>DiStarGPS</h1>
<p>ดูแลการเดินรถของคุณ</p>
</body>

</html>
2 changes: 1 addition & 1 deletion projects/teamcity-download-artifact.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# 默认使用名为artifacts的token, 权限较小(被设置为: `<Root project>: View build runtime parameters and data`)
# @see http://th-ci.transcodegroup.cn:9080/profile.html?item=accessTokens
Expand Down
1 change: 1 addition & 0 deletions web-downloader/.env
4 changes: 4 additions & 0 deletions web-downloader/compose.bus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
web-downloader-bus:
# Remove the profiles field to enable the service
profiles: !reset null
4 changes: 4 additions & 0 deletions web-downloader/compose.track.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
web-downloader-track:
# Remove the profiles field to enable the service
profiles: !reset null
43 changes: 43 additions & 0 deletions web-downloader/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
services:
web-downloader-base:
# All web-downloader-base/bus/track services are disabled by default
profiles: ["disabled"]
image: alpine/curl
command: /home/docker/web-downloader/web-downloader.sh
volumes:
- "${DATA_DIR:-/data}/nginx/html:/data/nginx/html"
configs:
- source: web-downloader.sh
target: /home/docker/web-downloader/web-downloader.sh
- source: teamcity-download-artifact.sh
target: /home/docker/projects/teamcity-download-artifact.sh

web-downloader-bus:
extends: web-downloader-base
volumes:
- ${BUS_WEB_OVERRIDE_DIR:?required}:${BUS_WEB_OVERRIDE_DIR:?required}
environment:
# tag starts with 'v', eg: v5.30.0
- TEAMCITY_TAG=v${BUS_WEB_VERSION:?required}
- TEAMCITY_BUILD_NAME=CityBusVueAdmin_Release
- TEAMCITY_BUILD_ZIP_NAME=bus.zip
- NGINX_HTML_DIR_NAME=bus
- NGINX_HTML_OVERRIDE_DIR=${BUS_WEB_OVERRIDE_DIR:?required}

web-downloader-track:
extends: web-downloader-base
volumes:
- ${TRACK_WEB_OVERRIDE_DIR:?required}:${TRACK_WEB_OVERRIDE_DIR:?required}
environment:
# tag starts with 'v', eg: v1.53.0
- TEAMCITY_TAG=v${TRACK_WEB_VERSION:?required}
- TEAMCITY_BUILD_NAME=MaintainVbenAdmin_Release
- TEAMCITY_BUILD_ZIP_NAME=maintain.zip
- NGINX_HTML_DIR_NAME=track
- NGINX_HTML_OVERRIDE_DIR=${TRACK_WEB_OVERRIDE_DIR:?required}

configs:
web-downloader.sh:
file: ./web-downloader.sh
teamcity-download-artifact.sh:
file: ../projects/teamcity-download-artifact.sh
51 changes: 51 additions & 0 deletions web-downloader/web-downloader.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh
set -e

if [ -z "${TEAMCITY_BUILD_NAME}" ]; then
echo "Please set these environment variables:"
echo "TEAMCITY_BUILD_NAME, TEAMCITY_TAG, TEAMCITY_BUILD_ZIP_NAME, NGINX_HTML_DIR_NAME, NGINX_HTML_OVERRIDE_DIR"
exit 1
fi

cd /data/nginx/html || exit 1

version_file="${NGINX_HTML_DIR_NAME}/.version-for-web-downloader"
override_dir="${NGINX_HTML_OVERRIDE_DIR:-"${NGINX_HTML_DIR_NAME}-override"}"

cp_override_files () {
if [ -d "$override_dir" ]; then
echo "Copy $override_dir into ${NGINX_HTML_DIR_NAME}..."
cp -vRT "$override_dir" "${NGINX_HTML_DIR_NAME}"
fi
}


# Check if the version already exists
if [ -f "$version_file" ]; then
current_version=$(cat "$version_file")
if [ "$current_version" = "${TEAMCITY_TAG}" ]; then
cp_override_files
echo "Version ${TEAMCITY_TAG} already exists"
exit 0
fi
fi

# Download the new version
/home/docker/projects/teamcity-download-artifact.sh --build="${TEAMCITY_BUILD_NAME}" --tag="${TEAMCITY_TAG}"

# Unzip
unzip "${TEAMCITY_BUILD_NAME}-${TEAMCITY_TAG}.zip"
if [ -e "${NGINX_HTML_DIR_NAME}" ]; then
rm -rf "${NGINX_HTML_DIR_NAME}"
fi
unzip "${TEAMCITY_BUILD_ZIP_NAME}" -d "${NGINX_HTML_DIR_NAME}"
cp_override_files

# Clean up
rm -f "${TEAMCITY_BUILD_ZIP_NAME}"
# rm "${TEAMCITY_BUILD_NAME}-${TEAMCITY_TAG}.zip"
echo "${TEAMCITY_TAG}" > "$version_file"

echo
echo "Downloaded version ${TEAMCITY_TAG}"
echo