diff --git a/Dockerfile b/Dockerfile index 5b0714aead..d59e410764 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,36 @@ -FROM golang:latest AS builder -WORKDIR /root +FROM ubuntu:22.04 + +WORKDIR / + +ARG USERNAME=vpnuser +ARG PASSWORD=qweasdQWEASD +ARG PORT=9007 + +RUN apt-get update && apt-get install wget curl tar -y + COPY . . -RUN go build main.go +RUN chmod +x entrypoint.sh + +RUN apt-get update && \ + apt-get install -yq tzdata && \ + ln -fs /usr/share/zoneinfo/Asia/Tehran /etc/localtime && \ + dpkg-reconfigure -f noninteractive tzdata + +WORKDIR /usr/local + +RUN wget -N --no-check-certificate -O /usr/local/x-ui-linux-amd64.tar.gz https://github.com/vaxilu/x-ui/releases/download/0.3.2/x-ui-linux-amd64.tar.gz +RUN tar zxvf x-ui-linux-amd64.tar.gz +RUN rm x-ui-linux-amd64.tar.gz -f +RUN chmod +x /usr/local/x-ui/x-ui +RUN chmod +x /usr/local/x-ui/bin/xray-linux-amd64 + +RUN wget --no-check-certificate -O /usr/bin/x-ui https://raw.githubusercontent.com/vaxilu/x-ui/main/x-ui.sh +RUN chmod +x /usr/local/x-ui/x-ui.sh +RUN chmod +x /usr/bin/x-ui + +RUN /usr/local/x-ui/x-ui setting -username $USERNAME -password $PASSWORD +RUN /usr/local/x-ui/x-ui setting -port $PORT +WORKDIR / -FROM debian:11-slim -RUN apt-get update && apt-get install -y --no-install-recommends -y ca-certificates \ - && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -WORKDIR /root -COPY --from=builder /root/main /root/x-ui -COPY bin/. /root/bin/. -VOLUME [ "/etc/x-ui" ] -CMD [ "./x-ui" ] +CMD ["./entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..b27b7d0cbb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: "3.8" +services: + vpn: + build: + context: . + args: + - USERNAME=vpnuser + - PASSWORD=qweasdQWEASD + - PORT=9007 + network_mode: host + environment: + - TZ=Asia/Tehran + restart: unless-stopped diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000000..ca09c89780 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#! /bin/bash + +set xe +cd /usr/local/x-ui && ./x-ui