45 lines
1.8 KiB
Docker
45 lines
1.8 KiB
Docker
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim
|
|
|
|
WORKDIR /app
|
|
|
|
ARG XRAY_VERSION=""
|
|
ARG TARGETARCH
|
|
ARG APT_MIRROR="https://mirrors.ustc.edu.cn/debian"
|
|
ARG UV_INDEX_URL="https://pypi.mirrors.ustc.edu.cn/simple/"
|
|
|
|
ENV UV_INDEX_URL="${UV_INDEX_URL}"
|
|
|
|
RUN if [ -f /etc/apt/sources.list.d/debian.sources ]; then \
|
|
sed -i "s|http://deb.debian.org/debian|${APT_MIRROR}|g; s|http://deb.debian.org/debian-security|${APT_MIRROR}-security|g" /etc/apt/sources.list.d/debian.sources; \
|
|
fi \
|
|
&& if [ -f /etc/apt/sources.list ]; then \
|
|
sed -i "s|http://deb.debian.org/debian|${APT_MIRROR}|g; s|http://security.debian.org/debian-security|${APT_MIRROR}-security|g" /etc/apt/sources.list; \
|
|
fi \
|
|
&& apt-get update \
|
|
&& apt-get install -y --no-install-recommends iproute2 iptables ca-certificates curl unzip \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN if [ -n "$XRAY_VERSION" ]; then \
|
|
case "$TARGETARCH" in \
|
|
amd64|"") XRAY_ARCH="64" ;; \
|
|
arm64) XRAY_ARCH="arm64-v8a" ;; \
|
|
arm) XRAY_ARCH="arm32-v7a" ;; \
|
|
*) echo "unsupported TARGETARCH: $TARGETARCH" >&2; exit 1 ;; \
|
|
esac; \
|
|
curl -fsSL "https://github.com/XTLS/Xray-core/releases/download/${XRAY_VERSION}/Xray-linux-${XRAY_ARCH}.zip" -o /tmp/xray.zip; \
|
|
unzip /tmp/xray.zip xray geoip.dat geosite.dat -d /usr/local/share/xray; \
|
|
install -m 0755 /usr/local/share/xray/xray /usr/local/bin/xray; \
|
|
rm -f /tmp/xray.zip; \
|
|
fi
|
|
|
|
COPY pyproject.toml uv.lock README.md ./
|
|
COPY pyxray ./pyxray
|
|
|
|
RUN uv sync --frozen --no-dev
|
|
|
|
VOLUME ["/config"]
|
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["/app/.venv/bin/pyxray", "--nodes-file", "/config/nodes.toml", "--state-file", "/config/state.toml", "--runtime-file", "/config/runtime.toml", "web", "--host", "0.0.0.0", "--port", "8080", "--config-file", "/config/config.json", "--log-file", "/config/xray.log"]
|