From c20c4d63ce9839f0f08a34d2dc2931787c62b98e Mon Sep 17 00:00:00 2001 From: uzziel Date: Mon, 17 Apr 2023 09:47:10 +0330 Subject: [PATCH] adds Dockerfile --- .dockerignore | 6 ++++++ Dockerfile | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..4693da9b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.github +docker-compose.yaml +Dockerfile +install.sh +x-ui.sh +x-ui.service \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..41e26a5e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# ARG XRAY_VERSION=1.8.0 + +# Build stage +FROM golang:1.20.3-alpine3.17 AS build +WORKDIR /app +RUN apk update && apk add --no-cache --update gcc build-base +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN CGO_ENABLED=1 go build main.go + +# Runtime stage +FROM alpine:3.17.3 +# ARG XRAY_VERSION +ENV TZ=Asia/Tehran +WORKDIR /app +# RUN useradd -D -g '' xui +RUN apk update && apk add --no-cache --update ca-certificates tzdata && update-ca-certificates + +# Download xray-core binary and install it to /app/bin +# ADD https://github.com/XTLS/Xray-core/releases/download/v${XRAY_VERSION}/Xray-linux-64.zip /tmp/xray.zip +ADD https://github.com/mhsanaei/Xray-core/releases/latest/download/Xray-linux-64.zip /tmp/xray.zip +RUN unzip /tmp/xray.zip -d bin && rm /tmp/xray.zip && mv bin/xray bin/xray-linux-amd64 + +# Download latest rule files +ADD https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat \ + https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat \ + https://github.com/bootmortis/iran-hosted-domains/releases/latest/download/iran.dat \ + bin/ +COPY --from=build /app/main /app/x-ui +VOLUME [ "/etc/x-ui" ] +# USER xui +ENTRYPOINT ["/bin/sh", "-c", "ln -sf /proc/1/fd/1 /app/access.log; /app/x-ui"] +# CMD [ "/app/x-ui" ]