Fix Docker build without VPN proxy dependency

Make build proxy optional and use Arvan mirrors for apt/pip by default. Fixes 503 errors when xray proxy on 172.17.0.1:1081 is unavailable during Dokploy deploy.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-10 20:26:09 +03:30
parent 63d0699cdd
commit 384680cd82
3 changed files with 35 additions and 20 deletions
+4
View File
@@ -16,5 +16,9 @@ TEST_ROLLBACK_MINUTES=2
AUTO_TEST_INTERVAL_MINUTES=30
FLASK_ENV=production
# ─── Build (اختیاری — فقط اگر xray روی host فعال است) ───
# BUILD_HTTP_PROXY=http://172.17.0.1:1081
# BUILD_HTTPS_PROXY=http://172.17.0.1:1081
# ─── CLI روی host ───
MIRROR_CONTAINER_NAME=mirror-manager
+27 -17
View File
@@ -1,19 +1,25 @@
# میرور آروان — بدون نیاز به دسترسی مستقیم Docker Hub
# میرور آروان — بدون نیاز به Docker Hub یا VPN برای build
ARG BASE_IMAGE=docker.arvancloud.ir/library/python:3.12-slim-bookworm
FROM ${BASE_IMAGE}
# پروکسی برای مرحله build (apt + pip از طریق VPN سرور)
ARG HTTP_PROXY=http://172.17.0.1:1081
ARG HTTPS_PROXY=http://172.17.0.1:1081
ENV http_proxy=${HTTP_PROXY}
ENV https_proxy=${HTTPS_PROXY}
ENV HTTP_PROXY=${HTTP_PROXY}
ENV HTTPS_PROXY=${HTTPS_PROXY}
ENV no_proxy=localhost,127.0.0.1,172.17.0.1
ENV NO_PROXY=localhost,127.0.0.1,172.17.0.1
# پروکسی اختیاری — فقط اگر xray/VPN روی host فعال است (مثلاً BUILD_HTTP_PROXY=http://172.17.0.1:1081)
ARG BUILD_HTTP_PROXY=
ARG BUILD_HTTPS_PROXY=
ARG PYPI_INDEX=https://mirror.arvancloud.ir/pypi/simple
RUN echo 'Acquire::http::Proxy "http://172.17.0.1:1081";' > /etc/apt/apt.conf.d/99proxy && \
echo 'Acquire::https::Proxy "http://172.17.0.1:1081";' >> /etc/apt/apt.conf.d/99proxy
# apt: بدون پروکسی از میرور آروان؛ با پروکسی از VPN
RUN if [ -n "$BUILD_HTTP_PROXY" ]; then \
echo "Acquire::http::Proxy \"$BUILD_HTTP_PROXY\";" > /etc/apt/apt.conf.d/99proxy && \
echo "Acquire::https::Proxy \"${BUILD_HTTPS_PROXY:-$BUILD_HTTP_PROXY}\";" >> /etc/apt/apt.conf.d/99proxy; \
else \
for f in /etc/apt/sources.list /etc/apt/sources.list.d/*.sources /etc/apt/sources.list.d/*.list; do \
[ -f "$$f" ] || continue; \
sed -i \
-e 's|http://deb.debian.org/debian|https://mirror.arvancloud.ir/debian|g' \
-e 's|http://security.debian.org/debian-security|https://mirror.arvancloud.ir/debian|g' \
"$$f"; \
done; \
fi
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
@@ -25,20 +31,24 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
WORKDIR /app
COPY requirements.txt .
# pip از طریق پروکسی VPN (HTTP_PROXY) به PyPI رسمی — میرور آروان گاهی timeout می‌دهد
RUN pip install --no-cache-dir \
# pip از میرور آروان — بدون نیاز به پروکسی
RUN if [ -n "$BUILD_HTTP_PROXY" ]; then \
export http_proxy="$BUILD_HTTP_PROXY" https_proxy="${BUILD_HTTPS_PROXY:-$BUILD_HTTP_PROXY}"; \
fi && \
pip install --no-cache-dir \
--default-timeout=300 \
--retries 10 \
--index-url https://pypi.org/simple \
--index-url "${PYPI_INDEX}" \
--trusted-host mirror.arvancloud.ir \
-r requirements.txt
COPY . .
RUN mkdir -p /app/data
# حذف پروکسی برای runtime
# حذف پروکسی apt برای runtime
RUN rm -f /etc/apt/apt.conf.d/99proxy
ENV http_proxy= https_proxy= HTTP_PROXY= HTTPS_PROXY=
ENV HOST_ROOT=/host
ENV DATA_DIR=/app/data
+4 -3
View File
@@ -3,11 +3,12 @@ services:
build:
context: .
dockerfile: Dockerfile
network: host
args:
BASE_IMAGE: docker.arvancloud.ir/library/python:3.12-slim-bookworm
HTTP_PROXY: http://172.17.0.1:1081
HTTPS_PROXY: http://172.17.0.1:1081
PYPI_INDEX: https://mirror.arvancloud.ir/pypi/simple
# اختیاری — فقط اگر xray روی host فعال است:
BUILD_HTTP_PROXY: ${BUILD_HTTP_PROXY:-}
BUILD_HTTPS_PROXY: ${BUILD_HTTPS_PROXY:-}
container_name: mirror-manager
restart: unless-stopped
privileged: true