WHAT: Updates the application's default port from 8080 to 3004 across various Docker configurations and scripts. This includes changes to Dockerfiles, docker-compose files, and startup scripts. Also updates the vite config. WHY: Standardizes the port used by the application to 3004 for consistency and to avoid potential conflicts with other services that might be using port 8080. HOW: Modifies the `EXPOSE` directives in the Dockerfiles, the port mappings in the docker-compose files, the default port in the main application server file, the port in the vite config and the scripts that display the API URL.
42 lines
1.4 KiB
Bash
42 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
||
set -euo pipefail
|
||
|
||
echo "[Dream-Machine] 开发环境启动"
|
||
|
||
# 自动探测宿主机平台,允许环境变量覆盖
|
||
HOST_OS=$(uname -s 2>/dev/null || echo unknown)
|
||
HOST_ARCH=$(uname -m 2>/dev/null || echo unknown)
|
||
|
||
# 如果用户误传了 darwin/arm64,统一转换为 linux/arm64(Docker 只支持 Linux 基础镜像)
|
||
if [ "${DOCKER_PLATFORM:-}" = "darwin/arm64" ] || [ "${DOCKER_PLATFORM:-}" = "Darwin/arm64" ]; then
|
||
DOCKER_PLATFORM=linux/arm64
|
||
fi
|
||
|
||
if [ -z "${DOCKER_PLATFORM:-}" ]; then
|
||
case "${HOST_OS}-${HOST_ARCH}" in
|
||
Darwin-arm64) DOCKER_PLATFORM=linux/arm64 ;;
|
||
Darwin-x86_64) DOCKER_PLATFORM=linux/amd64 ;;
|
||
Linux-x86_64) DOCKER_PLATFORM=linux/amd64 ;;
|
||
Linux-aarch64) DOCKER_PLATFORM=linux/arm64 ;;
|
||
*) DOCKER_PLATFORM=linux/amd64 ;;
|
||
esac
|
||
fi
|
||
|
||
echo "- 宿主机: ${HOST_OS}/${HOST_ARCH}"
|
||
echo "- 容器镜像平台: ${DOCKER_PLATFORM} (Docker 仅支持 linux/*;可通过 DOCKER_PLATFORM 覆盖)"
|
||
echo "- 将使用外部构建的前端 (dist/)"
|
||
|
||
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
|
||
ROOT_DIR=$(cd "$SCRIPT_DIR/.." && pwd)
|
||
|
||
if [ ! -d "$ROOT_DIR/dist" ]; then
|
||
echo "[提示] 未检测到 dist/,将进行前端构建 (pnpm build)"
|
||
(cd "$ROOT_DIR" && pnpm run build)
|
||
fi
|
||
|
||
echo "[步骤] 启动 Docker Compose (开发)"
|
||
(cd "$ROOT_DIR/docker" && DOCKER_PLATFORM=${DOCKER_PLATFORM} docker compose -f docker-compose.dev.yml up -d --build)
|
||
|
||
echo "[完成] API: http://localhost:3004"
|
||
|
||
|