fix: 修复构建问题,方便快速构建
This commit is contained in:
@@ -2,6 +2,15 @@
|
|||||||
EDGE_DISPATCH_HOST=0.0.0.0
|
EDGE_DISPATCH_HOST=0.0.0.0
|
||||||
EDGE_DISPATCH_PORT=8060
|
EDGE_DISPATCH_PORT=8060
|
||||||
EDGE_MAX_DISPATCH_RECORDS=2000
|
EDGE_MAX_DISPATCH_RECORDS=2000
|
||||||
|
PYTHON_IMAGE=docker.m.daocloud.io/library/python:3.10-slim
|
||||||
|
APT_MIRROR=mirrors.aliyun.com
|
||||||
|
PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
|
||||||
|
PIP_TRUSTED_HOST=mirrors.aliyun.com
|
||||||
|
AUTO_PULL_LATEST=false
|
||||||
|
GIT_REPO_URL=
|
||||||
|
GIT_BRANCH=master
|
||||||
|
GIT_CLONE_DEPTH=1
|
||||||
|
GIT_PROJECT_SUBDIR=video_worker
|
||||||
|
|
||||||
# OSS (required in production)
|
# OSS (required in production)
|
||||||
OSS_ENABLED=true
|
OSS_ENABLED=true
|
||||||
|
|||||||
@@ -7,6 +7,15 @@ WS_POLL_INTERVAL_SEC=1.0
|
|||||||
EDGE_DISPATCH_HOST=0.0.0.0
|
EDGE_DISPATCH_HOST=0.0.0.0
|
||||||
EDGE_DISPATCH_PORT=8020
|
EDGE_DISPATCH_PORT=8020
|
||||||
EDGE_MAX_DISPATCH_RECORDS=2000
|
EDGE_MAX_DISPATCH_RECORDS=2000
|
||||||
|
PYTHON_IMAGE=docker.m.daocloud.io/library/python:3.10-slim
|
||||||
|
APT_MIRROR=mirrors.aliyun.com
|
||||||
|
PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
|
||||||
|
PIP_TRUSTED_HOST=mirrors.aliyun.com
|
||||||
|
AUTO_PULL_LATEST=false
|
||||||
|
GIT_REPO_URL=
|
||||||
|
GIT_BRANCH=master
|
||||||
|
GIT_CLONE_DEPTH=1
|
||||||
|
GIT_PROJECT_SUBDIR=video_worker
|
||||||
OSS_ENABLED=false
|
OSS_ENABLED=false
|
||||||
OSS_ENDPOINT=https://oss-cn-shanghai.aliyuncs.com
|
OSS_ENDPOINT=https://oss-cn-shanghai.aliyuncs.com
|
||||||
OSS_BUCKET=aiclw
|
OSS_BUCKET=aiclw
|
||||||
|
|||||||
@@ -4,10 +4,15 @@ services:
|
|||||||
context: .
|
context: .
|
||||||
dockerfile: docker/edge-dispatch/Dockerfile
|
dockerfile: docker/edge-dispatch/Dockerfile
|
||||||
args:
|
args:
|
||||||
PYTHON_IMAGE: registry.cn-hangzhou.aliyuncs.com/library/python:3.10-slim
|
PYTHON_IMAGE: ${PYTHON_IMAGE:-docker.m.daocloud.io/library/python:3.10-slim}
|
||||||
APT_MIRROR: mirrors.aliyun.com
|
APT_MIRROR: ${APT_MIRROR:-mirrors.aliyun.com}
|
||||||
PIP_INDEX_URL: https://mirrors.aliyun.com/pypi/simple/
|
PIP_INDEX_URL: ${PIP_INDEX_URL:-https://mirrors.aliyun.com/pypi/simple/}
|
||||||
PIP_TRUSTED_HOST: mirrors.aliyun.com
|
PIP_TRUSTED_HOST: ${PIP_TRUSTED_HOST:-mirrors.aliyun.com}
|
||||||
|
AUTO_PULL_LATEST: ${AUTO_PULL_LATEST:-false}
|
||||||
|
GIT_REPO_URL: ${GIT_REPO_URL:-}
|
||||||
|
GIT_BRANCH: ${GIT_BRANCH:-master}
|
||||||
|
GIT_CLONE_DEPTH: ${GIT_CLONE_DEPTH:-1}
|
||||||
|
GIT_PROJECT_SUBDIR: ${GIT_PROJECT_SUBDIR:-video_worker}
|
||||||
container_name: video-worker-center-dispatch
|
container_name: video-worker-center-dispatch
|
||||||
env_file:
|
env_file:
|
||||||
- .env.center
|
- .env.center
|
||||||
|
|||||||
@@ -4,10 +4,15 @@ services:
|
|||||||
context: .
|
context: .
|
||||||
dockerfile: docker/edge-dispatch/Dockerfile
|
dockerfile: docker/edge-dispatch/Dockerfile
|
||||||
args:
|
args:
|
||||||
PYTHON_IMAGE: registry.cn-hangzhou.aliyuncs.com/library/python:3.10-slim
|
PYTHON_IMAGE: ${PYTHON_IMAGE:-docker.m.daocloud.io/library/python:3.10-slim}
|
||||||
APT_MIRROR: mirrors.aliyun.com
|
APT_MIRROR: ${APT_MIRROR:-mirrors.aliyun.com}
|
||||||
PIP_INDEX_URL: https://mirrors.aliyun.com/pypi/simple/
|
PIP_INDEX_URL: ${PIP_INDEX_URL:-https://mirrors.aliyun.com/pypi/simple/}
|
||||||
PIP_TRUSTED_HOST: mirrors.aliyun.com
|
PIP_TRUSTED_HOST: ${PIP_TRUSTED_HOST:-mirrors.aliyun.com}
|
||||||
|
AUTO_PULL_LATEST: ${AUTO_PULL_LATEST:-false}
|
||||||
|
GIT_REPO_URL: ${GIT_REPO_URL:-}
|
||||||
|
GIT_BRANCH: ${GIT_BRANCH:-master}
|
||||||
|
GIT_CLONE_DEPTH: ${GIT_CLONE_DEPTH:-1}
|
||||||
|
GIT_PROJECT_SUBDIR: ${GIT_PROJECT_SUBDIR:-video_worker}
|
||||||
container_name: edge-dispatch-service
|
container_name: edge-dispatch-service
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
ARG PYTHON_IMAGE=registry.cn-hangzhou.aliyuncs.com/library/python:3.10-slim
|
ARG PYTHON_IMAGE=docker.m.daocloud.io/library/python:3.10-slim
|
||||||
FROM ${PYTHON_IMAGE}
|
FROM ${PYTHON_IMAGE}
|
||||||
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
@@ -9,19 +9,38 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
|||||||
ARG APT_MIRROR=mirrors.aliyun.com
|
ARG APT_MIRROR=mirrors.aliyun.com
|
||||||
ARG PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
|
ARG PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
|
||||||
ARG PIP_TRUSTED_HOST=mirrors.aliyun.com
|
ARG PIP_TRUSTED_HOST=mirrors.aliyun.com
|
||||||
|
ARG AUTO_PULL_LATEST=false
|
||||||
|
ARG GIT_REPO_URL=
|
||||||
|
ARG GIT_BRANCH=master
|
||||||
|
ARG GIT_CLONE_DEPTH=1
|
||||||
|
ARG GIT_PROJECT_SUBDIR=video_worker
|
||||||
|
|
||||||
RUN sed -i "s@deb.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list.d/debian.sources \
|
RUN sed -i "s@deb.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list.d/debian.sources \
|
||||||
&& sed -i "s@security.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list.d/debian.sources
|
&& sed -i "s@security.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list.d/debian.sources \
|
||||||
|
&& apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends git ca-certificates \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY requirements.txt /app/requirements.txt
|
COPY requirements.txt /tmp/local_requirements.txt
|
||||||
|
COPY app /tmp/local_app
|
||||||
RUN pip config set global.index-url "${PIP_INDEX_URL}" \
|
RUN pip config set global.index-url "${PIP_INDEX_URL}" \
|
||||||
&& pip config set global.trusted-host "${PIP_TRUSTED_HOST}" \
|
&& pip config set global.trusted-host "${PIP_TRUSTED_HOST}" \
|
||||||
|
&& if [ "${AUTO_PULL_LATEST}" = "true" ]; then \
|
||||||
|
if [ -z "${GIT_REPO_URL}" ]; then \
|
||||||
|
echo "[ERROR] AUTO_PULL_LATEST=true but GIT_REPO_URL is empty"; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
git clone --depth "${GIT_CLONE_DEPTH}" --branch "${GIT_BRANCH}" "${GIT_REPO_URL}" /tmp/repo; \
|
||||||
|
cp "/tmp/repo/${GIT_PROJECT_SUBDIR}/requirements.txt" /app/requirements.txt; \
|
||||||
|
cp -r "/tmp/repo/${GIT_PROJECT_SUBDIR}/app" /app/app; \
|
||||||
|
else \
|
||||||
|
cp /tmp/local_requirements.txt /app/requirements.txt; \
|
||||||
|
cp -r /tmp/local_app /app/app; \
|
||||||
|
fi \
|
||||||
&& pip install -r /app/requirements.txt
|
&& pip install -r /app/requirements.txt
|
||||||
|
|
||||||
COPY app /app/app
|
|
||||||
|
|
||||||
EXPOSE 8020
|
EXPOSE 8020
|
||||||
|
|
||||||
CMD ["python", "-m", "uvicorn", "app.edge_dispatch_service:app", "--host", "0.0.0.0", "--port", "8020"]
|
CMD ["python", "-m", "uvicorn", "app.edge_dispatch_service:app", "--host", "0.0.0.0", "--port", "8020"]
|
||||||
|
|||||||
@@ -16,9 +16,7 @@ fi
|
|||||||
|
|
||||||
if [ ! -f .env.center ]; then
|
if [ ! -f .env.center ]; then
|
||||||
cp .env.center.example .env.center
|
cp .env.center.example .env.center
|
||||||
echo "[ERROR] .env.center was missing; template created at .env.center"
|
echo "[INFO] .env.center was missing; template created at .env.center"
|
||||||
echo "Please edit OSS and port settings, then rerun this script."
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# hard split: center project name + dedicated compose/env file
|
# hard split: center project name + dedicated compose/env file
|
||||||
@@ -28,6 +26,28 @@ COMPOSE_FILE="docker-compose.center-dispatch.yml"
|
|||||||
EDGE_PORT=$(grep '^EDGE_DISPATCH_PORT=' .env.center | tail -n1 | cut -d'=' -f2- || true)
|
EDGE_PORT=$(grep '^EDGE_DISPATCH_PORT=' .env.center | tail -n1 | cut -d'=' -f2- || true)
|
||||||
EDGE_PORT="${EDGE_PORT:-8020}"
|
EDGE_PORT="${EDGE_PORT:-8020}"
|
||||||
|
|
||||||
|
# one-click defaults for pulling latest code at build time
|
||||||
|
DEFAULT_GIT_REPO_URL=""
|
||||||
|
if command -v git >/dev/null 2>&1; then
|
||||||
|
DEFAULT_GIT_REPO_URL="$(git config --get remote.origin.url || true)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export AUTO_PULL_LATEST="${AUTO_PULL_LATEST:-true}"
|
||||||
|
export GIT_REPO_URL="${GIT_REPO_URL:-$DEFAULT_GIT_REPO_URL}"
|
||||||
|
export GIT_BRANCH="${GIT_BRANCH:-master}"
|
||||||
|
export GIT_CLONE_DEPTH="${GIT_CLONE_DEPTH:-1}"
|
||||||
|
export GIT_PROJECT_SUBDIR="${GIT_PROJECT_SUBDIR:-video_worker}"
|
||||||
|
|
||||||
|
if [ "${AUTO_PULL_LATEST}" = "true" ] && [ -z "${GIT_REPO_URL}" ]; then
|
||||||
|
echo "[ERROR] AUTO_PULL_LATEST=true but GIT_REPO_URL is empty"
|
||||||
|
echo "[INFO] set GIT_REPO_URL in .env.center or export it before running"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[INFO] AUTO_PULL_LATEST=${AUTO_PULL_LATEST}"
|
||||||
|
echo "[INFO] GIT_REPO_URL=${GIT_REPO_URL}"
|
||||||
|
echo "[INFO] GIT_BRANCH=${GIT_BRANCH}"
|
||||||
|
|
||||||
docker compose \
|
docker compose \
|
||||||
--project-name "$PROJECT_NAME" \
|
--project-name "$PROJECT_NAME" \
|
||||||
--env-file .env.center \
|
--env-file .env.center \
|
||||||
|
|||||||
Reference in New Issue
Block a user