fix: 修复构建问题,方便快速构建

This commit is contained in:
Daniel
2026-04-07 01:48:50 +08:00
parent 174ffd3d50
commit 026ef6c2e3
6 changed files with 83 additions and 16 deletions

View File

@@ -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}
ENV PYTHONDONTWRITEBYTECODE=1 \
@@ -9,19 +9,38 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
ARG APT_MIRROR=mirrors.aliyun.com
ARG PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
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 \
&& 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
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}" \
&& 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
COPY app /app/app
EXPOSE 8020
CMD ["python", "-m", "uvicorn", "app.edge_dispatch_service:app", "--host", "0.0.0.0", "--port", "8020"]