From 410cb2bbfde604fccf34256c9f3c1d2fe7859eaf Mon Sep 17 00:00:00 2001 From: chenhuajian Date: Wed, 9 Dec 2020 14:02:20 +0800 Subject: [PATCH] xray dockerfile --- docker/{ => v2ray}/Dockerfile | 0 docker/{ => v2ray}/run.sh | 0 docker/xray/Dockerfile | 38 +++++++++++++++++++++++++++++++++++ docker/xray/run.sh | 11 ++++++++++ 4 files changed, 49 insertions(+) rename docker/{ => v2ray}/Dockerfile (100%) rename docker/{ => v2ray}/run.sh (100%) create mode 100644 docker/xray/Dockerfile create mode 100644 docker/xray/run.sh diff --git a/docker/Dockerfile b/docker/v2ray/Dockerfile similarity index 100% rename from docker/Dockerfile rename to docker/v2ray/Dockerfile diff --git a/docker/run.sh b/docker/v2ray/run.sh similarity index 100% rename from docker/run.sh rename to docker/v2ray/run.sh diff --git a/docker/xray/Dockerfile b/docker/xray/Dockerfile new file mode 100644 index 00000000..71df0345 --- /dev/null +++ b/docker/xray/Dockerfile @@ -0,0 +1,38 @@ +FROM centos:latest as builder + +RUN curl -L -s https://multi.netlify.app/go.sh -o go.sh && bash go.sh -x + +FROM alpine:latest + +LABEL maintainer "Jrohy " + +ENV COMPLETION_FILE "/usr/share/bash-completion/completions/xray" + +ENV SOURCE_COMPLETION_FILE "https://multi.netlify.app/v2ray" + +ENV VERSION_LIST "https://api.github.com/repos/Jrohy/multi-v2ray/tags" + +COPY --from=builder /usr/bin/xray/xray /usr/bin/xray/ +COPY --from=builder /usr/bin/xray/geoip.dat /usr/bin/xray/ +COPY --from=builder /usr/bin/xray/geosite.dat /usr/bin/xray/ +COPY run.sh /root + +WORKDIR /root + +RUN apk --no-cache add python3 bash bash-completion ca-certificates curl socat openssl iptables ip6tables && \ + python3 -m ensurepip && \ + rm -r /usr/lib/python*/ensurepip && \ + pip3 install --upgrade pip setuptools && \ + LATEST_VERSION=`curl -s $VERSION_LIST|grep name|grep -o "[0-9].*[0-9]"|head -n 1` && \ + pip install v2ray-util==$LATEST_VERSION && \ + curl $SOURCE_COMPLETION_FILE > $COMPLETION_FILE && \ + sed -i 's/v2ray/xray/g' $COMPLETION_FILE && \ + mkdir /var/log/xray/ && \ + chmod +x /usr/bin/xray/xray && \ + chmod +x /root/run.sh && \ + chmod +x $COMPLETION_FILE && \ + echo "source $COMPLETION_FILE" > /root/.bashrc && \ + ln -s $(which v2ray-util) /usr/local/bin/xray && \ + rm -r /root/.cache + +ENTRYPOINT ["./run.sh"] \ No newline at end of file diff --git a/docker/xray/run.sh b/docker/xray/run.sh new file mode 100644 index 00000000..78b7ff58 --- /dev/null +++ b/docker/xray/run.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +if [[ ! -e /etc/xray ]];then + mkdir /etc/xray + xray new >/dev/null 2>&1 +fi + +touch /.run.log +/usr/bin/xray/xray -config=/etc/xray/config.json > /.run.log & + +tail -f /.run.log \ No newline at end of file