mirror of
https://github.com/teddysun/across.git
synced 2025-01-18 22:09:35 +08:00
Added Xray Docker Image
This commit is contained in:
parent
72513bfedb
commit
9e8fadd745
26
docker/xray/Dockerfile
Normal file
26
docker/xray/Dockerfile
Normal file
@ -0,0 +1,26 @@
|
||||
# Dockerfile for xray based alpine
|
||||
# Copyright (C) 2019 - 2020 Teddysun <i@teddysun.com>
|
||||
# Reference URL:
|
||||
# https://github.com/XTLS/Xray-core
|
||||
# https://github.com/v2ray/v2ray-core
|
||||
# https://github.com/v2ray/geoip
|
||||
# https://github.com/v2ray/domain-list-community
|
||||
|
||||
FROM alpine:latest
|
||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||
|
||||
WORKDIR /root
|
||||
COPY xray.sh /root/xray.sh
|
||||
COPY config.json /etc/xray/config.json
|
||||
RUN set -ex \
|
||||
&& apk add --no-cache tzdata ca-certificates \
|
||||
&& mkdir -p /var/log/xray \
|
||||
&& chmod +x /root/xray.sh \
|
||||
&& /root/xray.sh \
|
||||
&& rm -fv /root/xray.sh \
|
||||
&& wget -O /usr/bin/geosite.dat https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat \
|
||||
&& wget -O /usr/bin/geoip.dat https://github.com/v2fly/geoip/releases/latest/download/geoip.dat
|
||||
|
||||
VOLUME /etc/xray
|
||||
ENV TZ=Asia/Shanghai
|
||||
CMD [ "/usr/bin/xray", "-config", "/etc/xray/config.json" ]
|
27
docker/xray/Dockerfile.architecture
Normal file
27
docker/xray/Dockerfile.architecture
Normal file
@ -0,0 +1,27 @@
|
||||
# Dockerfile for xray based alpine
|
||||
# Copyright (C) 2019 - 2020 Teddysun <i@teddysun.com>
|
||||
# Reference URL:
|
||||
# https://github.com/XTLS/Xray-core
|
||||
# https://github.com/v2ray/v2ray-core
|
||||
# https://github.com/v2ray/geoip
|
||||
# https://github.com/v2ray/domain-list-community
|
||||
|
||||
FROM --platform=${TARGETPLATFORM} alpine:latest
|
||||
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
WORKDIR /root
|
||||
COPY xray.sh /root/xray.sh
|
||||
COPY config.json /etc/xray/config.json
|
||||
RUN set -ex \
|
||||
&& apk add --no-cache tzdata ca-certificates \
|
||||
&& mkdir -p /var/log/xray \
|
||||
&& chmod +x /root/xray.sh \
|
||||
&& /root/xray.sh "${TARGETPLATFORM}" \
|
||||
&& rm -fv /root/xray.sh \
|
||||
&& wget -O /usr/bin/geosite.dat https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat \
|
||||
&& wget -O /usr/bin/geoip.dat https://github.com/v2fly/geoip/releases/latest/download/geoip.dat
|
||||
|
||||
VOLUME /etc/xray
|
||||
ENV TZ=Asia/Shanghai
|
||||
CMD [ "/usr/bin/xray", "-config", "/etc/xray/config.json" ]
|
70
docker/xray/README.md
Normal file
70
docker/xray/README.md
Normal file
@ -0,0 +1,70 @@
|
||||
## Xray Docker Image by Teddysun
|
||||
|
||||
[Xray][1] is a platform for building proxies to bypass network restrictions.
|
||||
|
||||
It secures your network connections and thus protects your privacy.
|
||||
|
||||
Docker images are built for quick deployment in various computing cloud providers.
|
||||
|
||||
For more information on docker and containerization technologies, refer to [official document][2].
|
||||
|
||||
## Prepare the host
|
||||
|
||||
If you need to install docker by yourself, follow the [official installation guide][3].
|
||||
|
||||
## Pull the image
|
||||
|
||||
```bash
|
||||
$ docker pull teddysun/xray
|
||||
```
|
||||
|
||||
This pulls the latest release of Xray.
|
||||
|
||||
It can be found at [Docker Hub][4].
|
||||
|
||||
## Start a container
|
||||
|
||||
You **must create a configuration file** `/etc/xray/config.json` in host at first:
|
||||
|
||||
```
|
||||
$ mkdir -p /etc/xray
|
||||
```
|
||||
|
||||
A sample in JSON like below:
|
||||
|
||||
```
|
||||
{
|
||||
"inbounds": [{
|
||||
"port": 9000,
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"clients": [
|
||||
{
|
||||
"id": "1eb6e917-774b-4a84-aff6-b058577c60a5",
|
||||
"level": 1,
|
||||
"alterId": 64
|
||||
}
|
||||
]
|
||||
}
|
||||
}],
|
||||
"outbounds": [{
|
||||
"protocol": "freedom",
|
||||
"settings": {}
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
Or generate a configuration file online by [https://tools.sprov.xyz/v2ray/](https://tools.sprov.xyz/v2ray/)
|
||||
|
||||
There is an example to start a container that listen on port `9000`, run as a Xray server like below:
|
||||
|
||||
```bash
|
||||
$ docker run -d -p 9000:9000 --name xray --restart=always -v /etc/xray:/etc/xray teddysun/xray
|
||||
```
|
||||
|
||||
**Warning**: The port number must be same as configuration and opened in firewall.
|
||||
|
||||
[1]: https://github.com/XTLS/Xray-core
|
||||
[2]: https://docs.docker.com/
|
||||
[3]: https://docs.docker.com/install/
|
||||
[4]: https://hub.docker.com/r/teddysun/xray/
|
43
docker/xray/build_xray.sh
Normal file
43
docker/xray/build_xray.sh
Normal file
@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This is a Shell script for build multi-architectures v2ray binary file
|
||||
#
|
||||
# Supported architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
|
||||
#
|
||||
# Copyright (C) 2020 Teddysun <i@teddysun.com>
|
||||
#
|
||||
# Reference URL:
|
||||
# https://github.com/XTLS/Xray-core
|
||||
|
||||
cur_dir="$(pwd)"
|
||||
|
||||
COMMANDS=( git go )
|
||||
for CMD in "${COMMANDS[@]}"; do
|
||||
if [ ! "$(command -v "${CMD}")" ]; then
|
||||
echo "${CMD} is not installed, please install it and try again" && exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
cd ${cur_dir}
|
||||
git clone https://github.com/XTLS/Xray-core.git
|
||||
cd Xray-core || exit 2
|
||||
|
||||
LDFLAGS="-s -w"
|
||||
ARCHS=( 386 amd64 arm arm64 ppc64le s390x )
|
||||
ARMS=( 6 7 )
|
||||
|
||||
for ARCH in ${ARCHS[@]}; do
|
||||
if [ "${ARCH}" = "arm" ]; then
|
||||
for V in ${ARMS[@]}; do
|
||||
echo "Building xray_linux_${ARCH}${V}"
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${V} go build -v -trimpath -ldflags "${LDFLAGS}" -o ${cur_dir}/xray_linux_${ARCH}${V} ./main || exit 1
|
||||
done
|
||||
else
|
||||
echo "Building xray_linux_${ARCH}"
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -trimpath -ldflags "${LDFLAGS}" -o ${cur_dir}/xray_linux_${ARCH} ./main || exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
chmod +x ${cur_dir}/xray_linux_*
|
||||
# clean up
|
||||
cd ${cur_dir} && rm -fr Xray-core
|
19
docker/xray/config.json
Normal file
19
docker/xray/config.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"inbounds": [{
|
||||
"port": 9000,
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"clients": [
|
||||
{
|
||||
"id": "1eb6e917-774b-4a84-aff6-b058577c60a5",
|
||||
"level": 1,
|
||||
"alterId": 64
|
||||
}
|
||||
]
|
||||
}
|
||||
}],
|
||||
"outbounds": [{
|
||||
"protocol": "freedom",
|
||||
"settings": {}
|
||||
}]
|
||||
}
|
52
docker/xray/xray.sh
Normal file
52
docker/xray/xray.sh
Normal file
@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This is a Shell script for xray based alpine with Docker image
|
||||
#
|
||||
# Copyright (C) 2019 - 2020 Teddysun <i@teddysun.com>
|
||||
#
|
||||
# Reference URL:
|
||||
# https://github.com/XTLS/Xray-core
|
||||
|
||||
PLATFORM=$1
|
||||
if [ -z "$PLATFORM" ]; then
|
||||
ARCH="amd64"
|
||||
else
|
||||
case "$PLATFORM" in
|
||||
linux/386)
|
||||
ARCH="386"
|
||||
;;
|
||||
linux/amd64)
|
||||
ARCH="amd64"
|
||||
;;
|
||||
linux/arm/v6)
|
||||
ARCH="arm6"
|
||||
;;
|
||||
linux/arm/v7)
|
||||
ARCH="arm7"
|
||||
;;
|
||||
linux/arm64|linux/arm64/v8)
|
||||
ARCH="arm64"
|
||||
;;
|
||||
linux/ppc64le)
|
||||
ARCH="ppc64le"
|
||||
;;
|
||||
linux/s390x)
|
||||
ARCH="s390x"
|
||||
;;
|
||||
*)
|
||||
ARCH=""
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
[ -z "${ARCH}" ] && echo "Error: Not supported OS Architecture" && exit 1
|
||||
# Download binary file
|
||||
XRAY_FILE="xray_linux_${ARCH}"
|
||||
|
||||
echo "Downloading binary file: ${XRAY_FILE}"
|
||||
wget -O /usr/bin/xray https://dl.lamp.sh/files/${XRAY_FILE} > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to download binary file: ${XRAY_FILE}" && exit 1
|
||||
fi
|
||||
echo "Download binary file: ${XRAY_FILE} completed"
|
||||
|
||||
chmod +x /usr/bin/xray
|
Loading…
x
Reference in New Issue
Block a user