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:
@@ -16,5 +16,9 @@ TEST_ROLLBACK_MINUTES=2
|
|||||||
AUTO_TEST_INTERVAL_MINUTES=30
|
AUTO_TEST_INTERVAL_MINUTES=30
|
||||||
FLASK_ENV=production
|
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 ───
|
# ─── CLI روی host ───
|
||||||
MIRROR_CONTAINER_NAME=mirror-manager
|
MIRROR_CONTAINER_NAME=mirror-manager
|
||||||
|
|||||||
+27
-17
@@ -1,19 +1,25 @@
|
|||||||
# میرور آروان — بدون نیاز به دسترسی مستقیم Docker Hub
|
# میرور آروان — بدون نیاز به Docker Hub یا VPN برای build
|
||||||
ARG BASE_IMAGE=docker.arvancloud.ir/library/python:3.12-slim-bookworm
|
ARG BASE_IMAGE=docker.arvancloud.ir/library/python:3.12-slim-bookworm
|
||||||
FROM ${BASE_IMAGE}
|
FROM ${BASE_IMAGE}
|
||||||
|
|
||||||
# پروکسی برای مرحله build (apt + pip از طریق VPN سرور)
|
# پروکسی اختیاری — فقط اگر xray/VPN روی host فعال است (مثلاً BUILD_HTTP_PROXY=http://172.17.0.1:1081)
|
||||||
ARG HTTP_PROXY=http://172.17.0.1:1081
|
ARG BUILD_HTTP_PROXY=
|
||||||
ARG HTTPS_PROXY=http://172.17.0.1:1081
|
ARG BUILD_HTTPS_PROXY=
|
||||||
ENV http_proxy=${HTTP_PROXY}
|
ARG PYPI_INDEX=https://mirror.arvancloud.ir/pypi/simple
|
||||||
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
|
|
||||||
|
|
||||||
RUN echo 'Acquire::http::Proxy "http://172.17.0.1:1081";' > /etc/apt/apt.conf.d/99proxy && \
|
# apt: بدون پروکسی از میرور آروان؛ با پروکسی از VPN
|
||||||
echo 'Acquire::https::Proxy "http://172.17.0.1:1081";' >> /etc/apt/apt.conf.d/99proxy
|
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 \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
git \
|
git \
|
||||||
@@ -25,20 +31,24 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY requirements.txt .
|
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 \
|
--default-timeout=300 \
|
||||||
--retries 10 \
|
--retries 10 \
|
||||||
--index-url https://pypi.org/simple \
|
--index-url "${PYPI_INDEX}" \
|
||||||
|
--trusted-host mirror.arvancloud.ir \
|
||||||
-r requirements.txt
|
-r requirements.txt
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN mkdir -p /app/data
|
RUN mkdir -p /app/data
|
||||||
|
|
||||||
# حذف پروکسی برای runtime
|
# حذف پروکسی apt برای runtime
|
||||||
RUN rm -f /etc/apt/apt.conf.d/99proxy
|
RUN rm -f /etc/apt/apt.conf.d/99proxy
|
||||||
ENV http_proxy= https_proxy= HTTP_PROXY= HTTPS_PROXY=
|
|
||||||
|
|
||||||
ENV HOST_ROOT=/host
|
ENV HOST_ROOT=/host
|
||||||
ENV DATA_DIR=/app/data
|
ENV DATA_DIR=/app/data
|
||||||
|
|||||||
+4
-3
@@ -3,11 +3,12 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
network: host
|
|
||||||
args:
|
args:
|
||||||
BASE_IMAGE: docker.arvancloud.ir/library/python:3.12-slim-bookworm
|
BASE_IMAGE: docker.arvancloud.ir/library/python:3.12-slim-bookworm
|
||||||
HTTP_PROXY: http://172.17.0.1:1081
|
PYPI_INDEX: https://mirror.arvancloud.ir/pypi/simple
|
||||||
HTTPS_PROXY: http://172.17.0.1:1081
|
# اختیاری — فقط اگر xray روی host فعال است:
|
||||||
|
BUILD_HTTP_PROXY: ${BUILD_HTTP_PROXY:-}
|
||||||
|
BUILD_HTTPS_PROXY: ${BUILD_HTTPS_PROXY:-}
|
||||||
container_name: mirror-manager
|
container_name: mirror-manager
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
privileged: true
|
privileged: true
|
||||||
|
|||||||
Reference in New Issue
Block a user