diff --git a/.devcontainer/devcontainer-lock.json b/.devcontainer/devcontainer-lock.json new file mode 100644 index 00000000..5c990995 --- /dev/null +++ b/.devcontainer/devcontainer-lock.json @@ -0,0 +1,9 @@ +{ + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "version": "2.17.0", + "resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:25b9f05705ffba7dbe503230ac76081419306f8c8bc88e0ce78c4ecd99a0c78c", + "integrity": "sha256:25b9f05705ffba7dbe503230ac76081419306f8c8bc88e0ce78c4ecd99a0c78c" + } + } +} diff --git a/.github/workflows/docker.yml.orig b/.github/workflows/docker.yml.orig new file mode 100644 index 00000000..0dd4847d --- /dev/null +++ b/.github/workflows/docker.yml.orig @@ -0,0 +1,62 @@ +name: Release 3X-UI for Docker + +permissions: + contents: read + packages: write + +on: + workflow_dispatch: + push: + tags: + - "v*.*.*" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + with: + submodules: true + + - name: Docker meta + id: meta + uses: docker/metadata-action@v6 + with: + images: | + hsanaeii/3x-ui + ghcr.io/mhsanaei/3x-ui + tags: | + type=ref,event=branch + type=ref,event=tag + type=semver,pattern={{version}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + with: + install: true + + - name: Login to Docker Hub + uses: docker/login-action@v4 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Login to GHCR + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v7 + with: + context: . + 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/.vscode/launch.json b/.vscode/launch.json index 8a969702..82a35d6c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -25,9 +25,9 @@ // Set to true to serve assets/templates directly from disk for development "XUI_DEBUG": "true", // Uncomment to override DB folder location (by default uses working dir on Windows when debug) - // "XUI_DB_FOLDER": "${workspaceFolder}", + "XUI_DB_FOLDER": "${workspaceFolder}", // Example: override log level (debug|info|notice|warn|error) - // "XUI_LOG_LEVEL": "debug" + "XUI_LOG_LEVEL": "debug" }, "console": "integratedTerminal" } diff --git a/Dockerfile b/Dockerfile index 06ddc638..ab7a7428 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # ======================================================== # Stage: Frontend (Vite) # ======================================================== -FROM --platform=$BUILDPLATFORM node:22-alpine AS frontend +FROM --platform=$BUILDPLATFORM reg.vados.ru/node:22-alpine AS frontend WORKDIR /src/frontend COPY frontend/package.json frontend/package-lock.json ./ RUN npm ci @@ -12,7 +12,9 @@ RUN npm run build # ======================================================== # Stage: Builder # ======================================================== -FROM golang:1.26-alpine AS builder +#ARG CI_REGISTRY=reg.vados.ru +FROM reg.vados.ru/golang:1.26-alpine AS builder +#FROM golang:1.26-alpine AS builder WORKDIR /app ARG TARGETARCH @@ -33,7 +35,8 @@ RUN ./DockerInit.sh "$TARGETARCH" # ======================================================== # Stage: Final Image of 3x-ui # ======================================================== -FROM alpine +#FROM alpine +FROM reg.vados.ru/alpine ENV TZ=Asia/Tehran WORKDIR /app @@ -43,13 +46,15 @@ RUN apk add --no-cache --update \ fail2ban \ bash \ curl \ - openssl + openssl \ + mc 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/web/translation /app/web/translation +ADD --from=builder config/mc.tar.gz /root/.config # Configure fail2ban RUN rm -f /etc/fail2ban/jail.d/alpine-ssh.conf \ @@ -63,8 +68,8 @@ RUN chmod +x \ /app/x-ui \ /usr/bin/x-ui -ENV XUI_ENABLE_FAIL2BAN="true" -EXPOSE 2053 +ENV XUI_ENABLE_FAIL2BAN="false" +EXPOSE 2904 VOLUME [ "/etc/x-ui" ] CMD [ "./x-ui" ] ENTRYPOINT [ "/app/DockerEntrypoint.sh" ] diff --git a/Dockerfile.diff b/Dockerfile.diff new file mode 100644 index 00000000..ca9bceb3 --- /dev/null +++ b/Dockerfile.diff @@ -0,0 +1,38 @@ +2,12d1 +< # Stage: Frontend (Vite) +< # ======================================================== +< FROM --platform=$BUILDPLATFORM node:22-alpine AS frontend +< WORKDIR /src/frontend +< COPY frontend/package.json frontend/package-lock.json ./ +< RUN npm ci +< COPY frontend/ ./ +< COPY web/translation /src/web/translation +< RUN npm run build +< +< # ======================================================== +15,16c4,7 +< FROM golang:1.26-alpine AS builder +< WORKDIR /app +--- +> ARG CI_REGISTRY=reg.vados.ru +> ARG CI_BASE=${CI_REGISTRY}/golang:1.26-alpine +> FROM ${CI_BASE} AS builder +> WORKDIR "/app" +26d16 +< COPY --from=frontend /src/web/dist ./web/dist +36c26,27 +< FROM alpine +--- +> +> FROM ${CI_REGISTRY}/alpine +38c29 +< WORKDIR /app +--- +> WORKDIR "/app" +45a37 +> mc \ +51,52c43 +< COPY --from=builder /app/web/translation /app/web/translation +< +--- +> ADD config/mc.tar.gz /root/.config diff --git a/Dockerfile.orig b/Dockerfile.orig new file mode 100644 index 00000000..06ddc638 --- /dev/null +++ b/Dockerfile.orig @@ -0,0 +1,70 @@ +# ======================================================== +# Stage: Frontend (Vite) +# ======================================================== +FROM --platform=$BUILDPLATFORM node:22-alpine AS frontend +WORKDIR /src/frontend +COPY frontend/package.json frontend/package-lock.json ./ +RUN npm ci +COPY frontend/ ./ +COPY web/translation /src/web/translation +RUN npm run build + +# ======================================================== +# Stage: Builder +# ======================================================== +FROM golang:1.26-alpine AS builder +WORKDIR /app +ARG TARGETARCH + +RUN apk --no-cache --update add \ + build-base \ + gcc \ + curl \ + unzip + +COPY . . +COPY --from=frontend /src/web/dist ./web/dist + +ENV CGO_ENABLED=1 +ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE" +RUN go build -ldflags "-w -s" -o build/x-ui main.go +RUN ./DockerInit.sh "$TARGETARCH" + +# ======================================================== +# Stage: Final Image of 3x-ui +# ======================================================== +FROM alpine +ENV TZ=Asia/Tehran +WORKDIR /app + +RUN apk add --no-cache --update \ + ca-certificates \ + tzdata \ + fail2ban \ + bash \ + curl \ + openssl + +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/web/translation /app/web/translation + + +# Configure fail2ban +RUN rm -f /etc/fail2ban/jail.d/alpine-ssh.conf \ + && cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local \ + && sed -i "s/^\[ssh\]$/&\nenabled = false/" /etc/fail2ban/jail.local \ + && sed -i "s/^\[sshd\]$/&\nenabled = false/" /etc/fail2ban/jail.local \ + && sed -i "s/#allowipv6 = auto/allowipv6 = auto/g" /etc/fail2ban/fail2ban.conf + +RUN chmod +x \ + /app/DockerEntrypoint.sh \ + /app/x-ui \ + /usr/bin/x-ui + +ENV XUI_ENABLE_FAIL2BAN="true" +EXPOSE 2053 +VOLUME [ "/etc/x-ui" ] +CMD [ "./x-ui" ] +ENTRYPOINT [ "/app/DockerEntrypoint.sh" ] diff --git a/Dockerfile.vados b/Dockerfile.vados new file mode 100644 index 00000000..0fa9916f --- /dev/null +++ b/Dockerfile.vados @@ -0,0 +1,61 @@ +# ======================================================== +# Stage: Builder +# ======================================================== +ARG CI_REGISTRY=reg.vados.ru +ARG CI_BASE=${CI_REGISTRY}/golang:1.26-alpine +FROM ${CI_BASE} AS builder +WORKDIR "/app" +ARG TARGETARCH + +RUN apk --no-cache --update add \ + build-base \ + gcc \ + curl \ + unzip + +COPY . . + +ENV CGO_ENABLED=1 +ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE" +RUN go build -ldflags "-w -s" -o build/x-ui main.go +RUN ./DockerInit.sh "$TARGETARCH" + +# ======================================================== +# Stage: Final Image of 3x-ui +# ======================================================== + +FROM ${CI_REGISTRY}/alpine +ENV TZ=Asia/Tehran +WORKDIR "/app" + +RUN apk add --no-cache --update \ + ca-certificates \ + tzdata \ + fail2ban \ + bash \ + curl \ + mc \ + openssl + +COPY --from=builder /app/build/ /app/ +COPY --from=builder /app/DockerEntrypoint.sh /app/ +COPY --from=builder /app/x-ui.sh /usr/bin/x-ui +ADD config/mc.tar.gz /root/.config + +# Configure fail2ban +RUN rm -f /etc/fail2ban/jail.d/alpine-ssh.conf \ + && cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local \ + && sed -i "s/^\[ssh\]$/&\nenabled = false/" /etc/fail2ban/jail.local \ + && sed -i "s/^\[sshd\]$/&\nenabled = false/" /etc/fail2ban/jail.local \ + && sed -i "s/#allowipv6 = auto/allowipv6 = auto/g" /etc/fail2ban/fail2ban.conf + +RUN chmod +x \ + /app/DockerEntrypoint.sh \ + /app/x-ui \ + /usr/bin/x-ui + +ENV XUI_ENABLE_FAIL2BAN="true" +EXPOSE 2053 +VOLUME [ "/etc/x-ui" ] +CMD [ "./x-ui" ] +ENTRYPOINT [ "/app/DockerEntrypoint.sh" ] diff --git a/brun.sh b/brun.sh new file mode 100755 index 00000000..a2226d30 --- /dev/null +++ b/brun.sh @@ -0,0 +1,28 @@ +#!/bin/bash + + +CI_REGISTRY="reg.vados.ru" +#CI_BASE="$CI_REGISTRY/golang:1.26-alpine" +#CI_FROM="$CI_REGISTRY/alpine" +#CI_PROJECT="3x-ui" +#WORKDIR="/app" +#TARGETARCH="linux/amd64" +CI_IMAGE="$CI_REGISTRY/3xui_app" + +#CI_BUILD_ENGINE="buildx" +#CI_BUILDX_BUILDER="buildx_buildkit_custom_3x-ui-ci" + +#CI_TAGET="--push" +#--load" + +#export $CI_REGISTRY $CI_BASE $CI_FROM $CI_PROJECT $WORKDIR $TARGETARCH $CI_IMAGE $CI_BUILD_ENGINE $CI_BUILDX_BUILDER + +docker build --progress=plain --no-cache --push -t $CI_IMAGE -f Dockerfile . + +#docker push $CI_IMAGE + + +#docker buildx create --name $CI_BUILDX_BUILDER --driver docker-container --use ; + +#docker buildx build --builder $CI_BUILDX_BUILDER --progress=plain --platform $CI_BUILDX_PLATFORMS \ +# --build-arg CI_BASE_IMAGE=$CI_BASE_IMAGE $CI_TARGET -t $CI_IMAGE -f Dockerfile diff --git a/compose-run.sh b/compose-run.sh new file mode 100755 index 00000000..9c5550e3 --- /dev/null +++ b/compose-run.sh @@ -0,0 +1,12 @@ +#!/bin/bash +#--project-name=amster-registry +#docker network create -d bridge --attachable registry-ui-net + +#docker compose up -d --rem +#docker compose registry-ui stop +#docker cp registry-ui:/etc/nginx/nginx.conf tmp.conf +#ls -l tmp.conf + +docker-compose build --pull --no-cache +#docker-compose logs registry-ui +docker compose up -d diff --git a/docker-compose.yml b/docker-compose.yml index 311247e3..202bc00e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,8 +10,13 @@ services: - $PWD/cert/:/root/cert/ environment: XRAY_VMESS_AEAD_FORCED: "false" - XUI_ENABLE_FAIL2BAN: "true" + XUI_ENABLE_FAIL2BAN: "false" tty: true ports: +<<<<<<< HEAD - "2053:2053" restart: unless-stopped +======= + - "2904:2904" + restart: unless-stopped +>>>>>>> 36196363 (Edit files) diff --git a/install.sh b/install.sh old mode 100644 new mode 100755