diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1115de373..6440ddab5 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,4 +1,5 @@ name: Release 3X-UI for Docker + on: push: tags: @@ -6,36 +7,44 @@ on: workflow_dispatch: jobs: - build_and_push: + build: runs-on: ubuntu-latest steps: - - name: Check out the code + - name: Checkout repository uses: actions/checkout@v4.1.1 + with: + submodules: true + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/mhsanaei/3x-ui + tags: | + type=ref,event=branch + type=ref,event=tag + type=pep440,pattern={{version}} + - name: Set up QEMU uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3.0.0 - - name: Log in to GitHub Container Registry + - name: Login to GHCR uses: docker/login-action@v3.0.0 with: registry: ghcr.io - username: ${{ github.actor }} + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker meta - id: meta - uses: docker/metadata-action@v5.5.0 - with: - images: ghcr.io/${{ github.repository }} - - - name: Build and push Docker image + - name: Build and push uses: docker/build-push-action@v5.1.0 with: context: . - push: ${{ github.event_name != 'pull_request' }} - platforms: linux/amd64, linux/arm64/v8, linux/arm/v7, linux/arm/v6, linux/386 + push: true + platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/arm/v6,linux/386 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/DockerInit.sh b/DockerInit.sh index bbfcb04ea..a22249994 100755 --- a/DockerInit.sh +++ b/DockerInit.sh @@ -1,5 +1,4 @@ #!/bin/sh - case $1 in amd64) ARCH="64" @@ -21,28 +20,21 @@ case $1 in ARCH="arm32-v6" FNAME="armv6" ;; - armv5) - ARCH="arm32-v5" - FNAME="armv5" - ;; *) ARCH="64" FNAME="amd64" ;; esac - - mkdir -p build/bin cd build/bin - wget "https://github.com/XTLS/Xray-core/releases/download/v1.8.7/Xray-linux-${ARCH}.zip" unzip "Xray-linux-${ARCH}.zip" rm -f "Xray-linux-${ARCH}.zip" geoip.dat geosite.dat mv xray "xray-linux-${FNAME}" - wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat wget -O geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat wget -O geosite_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat wget -O geoip_VN.dat https://github.com/vuong2023/vn-v2ray-rules/releases/latest/download/geoip.dat wget -O geosite_VN.dat https://github.com/vuong2023/vn-v2ray-rules/releases/latest/download/geosite.dat +cd ../../ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 951d463b8..7db1a175e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,9 @@ # ======================================================== # Stage: Builder # ======================================================== -FROM --platform=$BUILDPLATFORM golang:1.21-alpine AS builder +FROM golang:1.21-alpine AS builder WORKDIR /app ARG TARGETARCH -ENV CGO_ENABLED=1 -ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE" RUN apk --no-cache --update add \ build-base \ @@ -15,6 +13,8 @@ RUN apk --no-cache --update add \ COPY . . +ENV CGO_ENABLED=1 +ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE" RUN go build -o build/x-ui main.go RUN ./DockerInit.sh "$TARGETARCH" @@ -30,9 +30,9 @@ RUN apk add --no-cache --update \ tzdata \ fail2ban -COPY --from=builder /app/build/ /app/ -COPY --from=builder /app/DockerEntrypoint.sh /app/ -COPY --from=builder /app/x-ui.sh /usr/bin/x-ui +COPY --from=builder /app/build/ /app/ +COPY --from=builder /app/DockerEntrypoint.sh /app/ +COPY --from=builder /app/x-ui.sh /usr/bin/x-ui # Configure fail2ban RUN rm -f /etc/fail2ban/jail.d/alpine-ssh.conf \ diff --git a/README.md b/README.md index 389d6d1d0..ec1e5a157 100644 --- a/README.md +++ b/README.md @@ -106,10 +106,19 @@ systemctl restart x-ui update to latest version ```sh - cd 3x-ui - docker compose down - docker compose pull 3x-ui - docker compose up -d + cd 3x-ui + docker compose down + docker compose pull 3x-ui + docker compose up -d + ``` + +remove 3x-ui from docker + + ```sh + docker stop 3x-ui + docker rm 3x-ui + cd -- + rm -r 3x-ui ``` diff --git a/install.sh b/install.sh index ae489c2af..9f46d4df8 100644 --- a/install.sh +++ b/install.sh @@ -123,9 +123,9 @@ config_after_install() { echo -e "${green}username:${usernameTemp}${plain}" echo -e "${green}password:${passwordTemp}${plain}" echo -e "###############################################" - echo -e "${red}if you forgot your login info,you can type x-ui and then type 7 to check after installation${plain}" + echo -e "${red}if you forgot your login info,you can type x-ui and then type 8 to check after installation${plain}" else - echo -e "${red} this is your upgrade,will keep old settings,if you forgot your login info,you can type x-ui and then type 7 to check${plain}" + echo -e "${red} this is your upgrade,will keep old settings,if you forgot your login info,you can type x-ui and then type 8 to check${plain}" fi fi /usr/local/x-ui/x-ui migrate diff --git a/x-ui.sh b/x-ui.sh index c7331e6dd..ffb20f06a 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -806,34 +806,6 @@ warp_cloudflare() { esac } -multi_protocol() { - echo "This script only supports Vless and Vmess. if you use another protocols, DON'T INSTALL or get backup first! " - echo -e "${green}\t1.${plain} Install Multi Protocol Script" - echo -e "${green}\t2.${plain} Uninstall" - echo -e "${green}\t3.${plain} Start Service" - echo -e "${green}\t4.${plain} Stop Service" - echo -e "${green}\t0.${plain} Back to Main Menu" - read -p "Choose an option: " choice - case "$choice" in - 0) - show_menu - ;; - 1) - bash <(curl -Ls https://raw.githubusercontent.com/M4mmad/3xui-multi-protocol/master/install.sh --ipv4) - ;; - 2) - bash <(curl -Ls https://raw.githubusercontent.com/M4mmad/3xui-multi-protocol/master/unistall.sh --ipv4) - ;; - 3) - systemctl start 3xui-multi-protocol - ;; - 4) - systemctl stop 3xui-multi-protocol - ;; - *) echo "Invalid choice" ;; - esac -} - run_speedtest() { # Check if Speedtest is already installed if ! command -v speedtest &>/dev/null; then @@ -1145,22 +1117,21 @@ show_menu() { ${green}12.${plain} Check Status ${green}13.${plain} Check Logs ———————————————— - ${green}14.${plain} Enable x-ui On System Startup - ${green}15.${plain} Disable x-ui On System Startup + ${green}14.${plain} Enable Autostart + ${green}15.${plain} Disable Autostart ———————————————— ${green}16.${plain} SSL Certificate Management ${green}17.${plain} Cloudflare SSL Certificate ${green}18.${plain} IP Limit Management ${green}19.${plain} WARP Management - ${green}20.${plain} Multi Protocol Management ———————————————— - ${green}21.${plain} Enable BBR - ${green}22.${plain} Update Geo Files - ${green}23.${plain} Active Firewall and open ports - ${green}24.${plain} Speedtest by Ookla + ${green}20.${plain} Enable BBR + ${green}21.${plain} Update Geo Files + ${green}22.${plain} Active Firewall and open ports + ${green}23.${plain} Speedtest by Ookla " show_status - echo && read -p "Please enter your selection [0-24]: " num + echo && read -p "Please enter your selection [0-23]: " num case "${num}" in 0) @@ -1224,22 +1195,19 @@ show_menu() { warp_cloudflare ;; 20) - multi_protocol - ;; - 21) enable_bbr ;; - 22) + 21) update_geo ;; - 23) + 22) open_ports ;; - 24) + 23) run_speedtest ;; *) - LOGE "Please enter the correct number [0-24]" + LOGE "Please enter the correct number [0-23]" ;; esac }