This commit is contained in:
2025-12-24 00:32:59 +03:00
parent 2d61830d08
commit 2a107b64e6
2 changed files with 20 additions and 9 deletions

View File

@@ -1,19 +1,29 @@
FROM alpine:3.20 FROM alpine:3.20
ARG SINGBOX_VER=1.8.10 ARG SINGBOX_VER=1.8.10
ARG VLESS_URL ARG VLESS_URL
RUN apk add --no-cache curl ca-certificates tar jq bash coreutils netcat-openbsd python3 && update-ca-certificates \
&& curl -L -o /tmp/sb.tar.gz https://github.com/SagerNet/sing-box/releases/download/v${SINGBOX_VER}/sing-box-${SINGBOX_VER}-linux-amd64.tar.gz \ # Устанавливаем зависимости, включая dos2unix для исправления скриптов
RUN apk add --no-cache curl ca-certificates tar jq bash coreutils netcat-openbsd python3 dos2unix && update-ca-certificates
# Автоматическое определение архитектуры и установка sing-box
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then SB_ARCH="amd64"; \
elif [ "$ARCH" = "aarch64" ]; then SB_ARCH="arm64"; \
else SB_ARCH="amd64"; fi && \
curl -L -o /tmp/sb.tar.gz https://github.com/SagerNet/sing-box/releases/download/v${SINGBOX_VER}/sing-box-${SINGBOX_VER}-linux-${SB_ARCH}.tar.gz \
&& tar -xf /tmp/sb.tar.gz -C /tmp \ && tar -xf /tmp/sb.tar.gz -C /tmp \
&& mv /tmp/sing-box-${SINGBOX_VER}-linux-amd64/sing-box /usr/local/bin/sing-box \ && mv /tmp/sing-box-${SINGBOX_VER}-linux-${SB_ARCH}/sing-box /usr/local/bin/sing-box \
&& chmod +x /usr/local/bin/sing-box \ && chmod +x /usr/local/bin/sing-box \
&& adduser -D -u 1000 suser && adduser -D -u 1000 suser
COPY --chown=suser:suser config/client.template.json /app/ COPY --chown=suser:suser config/client.template.json /app/
COPY --chown=suser:suser scripts/gen-client-from-url.sh scripts/menu.sh /app/ COPY --chown=suser:suser scripts/gen-client-from-url.sh scripts/menu.sh /app/
COPY --chown=suser:suser docker/entrypoint.sh /app/ COPY --chown=suser:suser docker/entrypoint.sh /app/
COPY --chown=suser:suser web/ /app/web/ COPY --chown=suser:suser web/ /app/web/
RUN chmod +x /app/gen-client-from-url.sh /app/entrypoint.sh /app/menu.sh
# Исправляем окончания строк (важно для Windows пользователей) и даем права на запуск
RUN dos2unix /app/*.sh && chmod +x /app/gen-client-from-url.sh /app/entrypoint.sh /app/menu.sh
ENV VLESS_URL=$VLESS_URL ENV VLESS_URL=$VLESS_URL
EXPOSE 8082 9090 3456 EXPOSE 8082 9090 3456
ENTRYPOINT ["/app/entrypoint.sh"] ENTRYPOINT ["/app/entrypoint.sh"]

View File

@@ -14,8 +14,9 @@ from pathlib import Path
PORT = 3456 PORT = 3456
APP_DIR = Path(__file__).parent APP_DIR = Path(__file__).parent
WEB_DIR = APP_DIR / "web" BASE_DIR = APP_DIR.parent
DATA_DIR = APP_DIR / "data" WEB_DIR = APP_DIR
DATA_DIR = BASE_DIR / "data"
CONFIG_FILE = DATA_DIR / "client.json" CONFIG_FILE = DATA_DIR / "client.json"
@@ -119,12 +120,12 @@ class ProxyControlHandler(http.server.BaseHTTPRequestHandler):
return return
# Run gen-client-from-url.sh # Run gen-client-from-url.sh
script_path = APP_DIR / "gen-client-from-url.sh" script_path = BASE_DIR / "gen-client-from-url.sh"
result = subprocess.run( result = subprocess.run(
[str(script_path), url, str(CONFIG_FILE)], [str(script_path), url, str(CONFIG_FILE)],
capture_output=True, capture_output=True,
text=True, text=True,
cwd=str(APP_DIR), cwd=str(BASE_DIR),
timeout=30 timeout=30
) )