49 lines
1.9 KiB
Docker
49 lines
1.9 KiB
Docker
ARG PYTHON_IMAGE=docker.m.daocloud.io/library/python:3.10-slim
|
|
FROM ${PYTHON_IMAGE}
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
|
PIP_NO_CACHE_DIR=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 \
|
|
&& apt-get update \
|
|
&& apt-get install -y --no-install-recommends git ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
COPY requirements-edge-dispatch.txt /tmp/local_edge_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-edge-dispatch.txt" /app/requirements.txt; \
|
|
cp -r "/tmp/repo/${GIT_PROJECT_SUBDIR}/app" /app/app; \
|
|
rm -rf /tmp/repo; \
|
|
else \
|
|
cp /tmp/local_edge_requirements.txt /app/requirements.txt; \
|
|
cp -r /tmp/local_app /app/app; \
|
|
fi \
|
|
&& pip install --no-cache-dir -r /app/requirements.txt \
|
|
&& rm -rf /tmp/local_app /tmp/local_edge_requirements.txt
|
|
|
|
EXPOSE 8020
|
|
|
|
CMD ["python", "-m", "uvicorn", "app.edge_dispatch_service:app", "--host", "0.0.0.0", "--port", "8020"]
|