mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-11-29 02:42:51 +00:00
Integrated unified sh scripts into docker build system + some cache updates
This commit is contained in:
parent
3a2988c068
commit
e1058b1eaf
5 changed files with 41 additions and 18 deletions
|
|
@ -7,3 +7,5 @@ docker-compose.yml
|
||||||
.tmp
|
.tmp
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
|
LICENSE
|
||||||
|
README.*
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Start fail2ban
|
# Start fail2ban
|
||||||
[ $XUI_ENABLE_FAIL2BAN == "true" ] && fail2ban-client -x start
|
[ "$XUI_ENABLE_FAIL2BAN" = "true" ] && fail2ban-client -x start
|
||||||
|
|
||||||
# Run x-ui
|
# Run x-ui
|
||||||
exec /app/x-ui
|
exec /app/x-ui
|
||||||
|
|
|
||||||
35
Dockerfile
35
Dockerfile
|
|
@ -2,27 +2,44 @@
|
||||||
# Stage: Builder
|
# Stage: Builder
|
||||||
# ========================================================
|
# ========================================================
|
||||||
FROM golang:1.25-alpine AS builder
|
FROM golang:1.25-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ARG TARGETARCH
|
|
||||||
|
|
||||||
RUN apk --no-cache --update add \
|
RUN apk --no-cache --update add \
|
||||||
build-base \
|
build-base \
|
||||||
gcc \
|
gcc
|
||||||
wget \
|
|
||||||
unzip
|
# docker CACHE
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
ENV CGO_ENABLED=1
|
ENV CGO_ENABLED=1
|
||||||
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
|
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
|
||||||
RUN go build -ldflags "-w -s" -o build/x-ui main.go
|
RUN go build -ldflags "-w -s" -o build/x-ui main.go
|
||||||
RUN ./DockerInit.sh "$TARGETARCH"
|
|
||||||
|
# ========================================================
|
||||||
|
# Stage: Xray downloader
|
||||||
|
# ========================================================
|
||||||
|
FROM alpine AS xray-downloader
|
||||||
|
|
||||||
|
ARG TARGETARCH
|
||||||
|
ARG XRAY_VERSION
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
RUN apk add --no-cache wget unzip
|
||||||
|
|
||||||
|
COPY xray-tools.sh .
|
||||||
|
RUN chmod +x /app/xray-tools.sh
|
||||||
|
RUN ./xray-tools.sh install_xray_core "$TARGETARCH" "/app/bin" "$XRAY_VERSION"
|
||||||
|
RUN ./xray-tools.sh update_geodata_in_docker "/app/bin"
|
||||||
|
|
||||||
# ========================================================
|
# ========================================================
|
||||||
# Stage: Final Image of 3x-ui
|
# Stage: Final Image of 3x-ui
|
||||||
# ========================================================
|
# ========================================================
|
||||||
FROM alpine
|
FROM alpine
|
||||||
ENV TZ=Asia/Tehran
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN apk add --no-cache --update \
|
RUN apk add --no-cache --update \
|
||||||
|
|
@ -31,9 +48,11 @@ RUN apk add --no-cache --update \
|
||||||
fail2ban \
|
fail2ban \
|
||||||
bash
|
bash
|
||||||
|
|
||||||
|
COPY DockerEntrypoint.sh /app/
|
||||||
COPY --from=builder /app/build/ /app/
|
COPY --from=builder /app/build/ /app/
|
||||||
COPY --from=builder /app/DockerEntrypoint.sh /app/
|
#COPY --from=builder /app/DockerEntrypoint.sh /app/
|
||||||
COPY --from=builder /app/x-ui.sh /usr/bin/x-ui
|
COPY --from=builder /app/x-ui.sh /usr/bin/x-ui
|
||||||
|
COPY --from=xray-downloader /app/bin /app/bin
|
||||||
|
|
||||||
|
|
||||||
# Configure fail2ban
|
# Configure fail2ban
|
||||||
|
|
@ -51,5 +70,5 @@ RUN chmod +x \
|
||||||
ENV XUI_ENABLE_FAIL2BAN="true"
|
ENV XUI_ENABLE_FAIL2BAN="true"
|
||||||
EXPOSE 2053
|
EXPOSE 2053
|
||||||
VOLUME [ "/etc/x-ui" ]
|
VOLUME [ "/etc/x-ui" ]
|
||||||
CMD [ "./x-ui" ]
|
#CMD [ "./x-ui" ]
|
||||||
ENTRYPOINT [ "/app/DockerEntrypoint.sh" ]
|
ENTRYPOINT [ "/app/DockerEntrypoint.sh" ]
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,15 @@ services:
|
||||||
3xui:
|
3xui:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./Dockerfile
|
args:
|
||||||
|
XRAY_VERSION: "v25.10.15"
|
||||||
|
GEOUPDATE_CRON_SCHEDULE: "0 */6 * * *"
|
||||||
container_name: 3xui_app
|
container_name: 3xui_app
|
||||||
# hostname: yourhostname <- optional
|
|
||||||
volumes:
|
volumes:
|
||||||
- $PWD/db/:/etc/x-ui/
|
- $PWD/db/:/etc/x-ui/
|
||||||
- $PWD/cert/:/root/cert/
|
- $PWD/cert/:/root/cert/
|
||||||
environment:
|
environment:
|
||||||
|
TZ: "Asia/Tehran"
|
||||||
XRAY_VMESS_AEAD_FORCED: "false"
|
XRAY_VMESS_AEAD_FORCED: "false"
|
||||||
XUI_ENABLE_FAIL2BAN: "true"
|
XUI_ENABLE_FAIL2BAN: "true"
|
||||||
tty: true
|
tty: true
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ update_geodata_in_docker() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
update_xray_core() {
|
install_xray_core() {
|
||||||
TARGETARCH="$1"
|
TARGETARCH="$1"
|
||||||
WORKDIR="$2"
|
WORKDIR="$2"
|
||||||
XRAY_VERSION="$3"
|
XRAY_VERSION="$3"
|
||||||
|
|
@ -46,7 +46,7 @@ update_xray_core() {
|
||||||
OLD_DIR=$(pwd)
|
OLD_DIR=$(pwd)
|
||||||
trap 'cd "$OLD_DIR"' EXIT
|
trap 'cd "$OLD_DIR"' EXIT
|
||||||
|
|
||||||
echo "[$(date)] Running update_xray_core"
|
echo "[$(date)] Running install_xray_core"
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
amd64)
|
amd64)
|
||||||
|
|
@ -94,9 +94,9 @@ if [ "${0##*/}" = "xray-tools.sh" ]; then
|
||||||
shift || true
|
shift || true
|
||||||
|
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
update_xray_core)
|
install_xray_core)
|
||||||
# args: TARGETARCH WORKDIR XRAY_VERSION
|
# args: TARGETARCH WORKDIR XRAY_VERSION
|
||||||
update_xray_core "$@"
|
install_xray_core "$@"
|
||||||
;;
|
;;
|
||||||
update_geodata_in_docker)
|
update_geodata_in_docker)
|
||||||
# args: WORKDIR
|
# args: WORKDIR
|
||||||
|
|
@ -104,7 +104,7 @@ if [ "${0##*/}" = "xray-tools.sh" ]; then
|
||||||
;;
|
;;
|
||||||
""|help|-h|--help)
|
""|help|-h|--help)
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo " $0 update_xray_core TARGETARCH WORKDIR XRAY_VERSION"
|
echo " $0 install_xray_core TARGETARCH WORKDIR XRAY_VERSION"
|
||||||
echo " $0 update_geodata_in_docker WORKDIR"
|
echo " $0 update_geodata_in_docker WORKDIR"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue