tag(修复):修复跨域错误

This commit is contained in:
OrangeRoll
2026-08-11 16:37:53 +08:00
parent 0f82920df0
commit b04c0ad43e
13 changed files with 202 additions and 104 deletions
+115 -8
View File
@@ -7,29 +7,136 @@ if [[ -z "$version" ]]; then
exit 1
fi
# 修改此处为本机 JDK 21 的实际安装目录。
project_java_home="/home/orangeroll/.jdks/ms-21.0.12"
if [[ ! -x "$project_java_home/bin/java" ]]; then
echo "Java 21 was not found at: $project_java_home"
echo "Update project_java_home in scripts/package-release.sh."
exit 1
fi
export JAVA_HOME="$project_java_home"
export PATH="$JAVA_HOME/bin:$PATH"
echo "Using Java: $JAVA_HOME"
if ! command -v npm >/dev/null 2>&1; then
echo "npm was not found. Install Node.js/npm before packaging."
exit 1
fi
script_dir="$(cd "$(dirname "$0")" && pwd)"
project_dir="$(cd "$script_dir/.." && pwd)"
release_dir="$project_dir/release"
bundle_dir="$release_dir/screen-share-$version"
archive="$release_dir/screen-share-$version.tar.gz"
if [[ -e "$bundle_dir" || -e "$archive" ]]; then
echo "Release already exists: $bundle_dir or $archive"
if ! mkdir -p "$release_dir" || [[ ! -w "$release_dir" ]]; then
echo "Release directory is not writable: $release_dir"
echo "Fix it once with: sudo chown -R \$USER:\$USER \"$release_dir\""
exit 1
fi
mkdir -p "$bundle_dir/infra/livekit" "$bundle_dir/infra/nginx" "$bundle_dir/docs"
if docker info >/dev/null 2>&1; then
docker_command=(docker)
else
docker_command=(sudo docker)
fi
docker build -t "screenshare-api:$version" "$project_dir/apps/ScreenShareApi"
docker build -t "screenshare-web:$version" "$project_dir/apps/ScreenShareWeb"
docker pull postgres:16-alpine
docker pull livekit/livekit-server:v1.9.10
run_docker() {
"${docker_command[@]}" "$@"
}
docker save + -o "$bundle_dir/images.tar" + "screenshare-api:$version" + "screenshare-web:$version" + postgres:16-alpine + livekit/livekit-server:v1.9.10
ensure_docker_image() {
local image="$1"
if run_docker image inspect "$image" >/dev/null 2>&1; then
echo "Using local Docker image: $image"
else
retry run_docker pull "$image"
fi
}
if [[ -e "$bundle_dir" || -e "$archive" ]]; then
if [[ -d "$bundle_dir" && ! -e "$archive" ]] && [[ -z "$(find "$bundle_dir" -type f -print -quit)" ]]; then
find "$bundle_dir" -depth -type d -empty -delete
else
echo "Release already exists: $bundle_dir or $archive"
exit 1
fi
fi
retry() {
local attempt
for attempt in 1 2 3; do
if "$@"; then
return 0
fi
if [[ "$attempt" -lt 3 ]]; then
echo "Command failed; retrying in 5 seconds ($attempt/3)..."
sleep 5
fi
done
return 1
}
docker_build() {
local build_args=()
local network_args=()
local proxy_enabled=false
local variable
local value
local build_network="${DOCKER_BUILD_NETWORK-}"
for variable in HTTP_PROXY HTTPS_PROXY NO_PROXY http_proxy https_proxy no_proxy; do
value="${!variable-}"
if [[ -n "$value" ]]; then
build_args+=(--build-arg "$variable=$value")
proxy_enabled=true
fi
done
if [[ "$proxy_enabled" == true ]]; then
echo "Using proxy environment variables for Docker build containers."
fi
if [[ -n "$build_network" ]]; then
network_args=(--network "$build_network")
echo "Using Docker build network: $build_network"
fi
run_docker build "${build_args[@]}" "${network_args[@]}" "$@"
}
build_api_distribution() {
(
cd "$project_dir/apps/ScreenShareApi"
./gradlew installDist --no-daemon
)
}
build_web_assets() {
(
cd "$project_dir/apps/ScreenShareWeb"
npm run build
)
}
build_api_distribution
build_web_assets
retry docker_build -t "screenshare-api:$version" "$project_dir/apps/ScreenShareApi"
ensure_docker_image postgres:16-alpine
ensure_docker_image livekit/livekit-server:v1.9.10
ensure_docker_image nginx:1.27-alpine
mkdir -p "$bundle_dir/infra/livekit" "$bundle_dir/infra/nginx" "$bundle_dir/docs" "$bundle_dir/web"
run_docker save \
"screenshare-api:$version" \
postgres:16-alpine \
livekit/livekit-server:v1.9.10 \
nginx:1.27-alpine \
> "$bundle_dir/images.tar"
cp -a "$project_dir/apps/ScreenShareWeb/dist/." "$bundle_dir/web/"
cp "$project_dir/docker-compose.yml" "$bundle_dir/"
cp "$project_dir/.env.example" "$bundle_dir/"
cp "$project_dir/infra/livekit/livekit.yaml" "$bundle_dir/infra/livekit/"
cp "$project_dir/infra/nginx/gateway.conf" "$bundle_dir/infra/nginx/"
cp "$project_dir/infra/nginx/screenshare.conf.example" "$bundle_dir/infra/nginx/"
cp "$project_dir/docs/SERVER_DEPLOYMENT.md" "$bundle_dir/docs/"