mirror of
https://github.com/teddysun/across.git
synced 2025-01-19 06:19:35 +08:00
Added Trojan-Go Docker Image
Signed-off-by: Teddysun <i@teddysun.com>
This commit is contained in:
parent
c86c65ba98
commit
d0fb2fb7bb
25
docker/trojan-go/Dockerfile
Normal file
25
docker/trojan-go/Dockerfile
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Dockerfile for trojan-go based alpine
|
||||||
|
# Copyright (C) 2019 - 2020 Teddysun <i@teddysun.com>
|
||||||
|
# Reference URL:
|
||||||
|
# https://github.com/p4gefau1t/trojan-go
|
||||||
|
# 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 trojan-go.sh /root/trojan-go.sh
|
||||||
|
COPY config.json /etc/trojan-go/config.json
|
||||||
|
RUN set -ex \
|
||||||
|
&& apk add --no-cache tzdata ca-certificates \
|
||||||
|
&& chmod +x /root/trojan-go.sh \
|
||||||
|
&& /root/trojan-go.sh \
|
||||||
|
&& rm -fv /root/trojan-go.sh \
|
||||||
|
&& wget -O /usr/bin/geosite.dat https://github.com/v2ray/domain-list-community/releases/latest/download/dlc.dat \
|
||||||
|
&& wget -O /usr/bin/geoip.dat https://github.com/v2ray/geoip/releases/latest/download/geoip.dat
|
||||||
|
|
||||||
|
VOLUME /etc/trojan-go
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
CMD [ "trojan-go", "-config", "/etc/trojan-go/config.json" ]
|
26
docker/trojan-go/Dockerfile.architecture
Normal file
26
docker/trojan-go/Dockerfile.architecture
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Dockerfile for trojan-go based alpine
|
||||||
|
# Copyright (C) 2019 - 2020 Teddysun <i@teddysun.com>
|
||||||
|
# Reference URL:
|
||||||
|
# https://github.com/p4gefau1t/trojan-go
|
||||||
|
# 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 trojan-go.sh /root/trojan-go.sh
|
||||||
|
COPY config.json /etc/trojan-go/config.json
|
||||||
|
RUN set -ex \
|
||||||
|
&& apk add --no-cache tzdata ca-certificates \
|
||||||
|
&& chmod +x /root/trojan-go.sh \
|
||||||
|
&& /root/trojan-go.sh "${TARGETPLATFORM}" \
|
||||||
|
&& rm -fv /root/trojan-go.sh \
|
||||||
|
&& wget -O /usr/bin/geosite.dat https://github.com/v2ray/domain-list-community/releases/latest/download/dlc.dat \
|
||||||
|
&& wget -O /usr/bin/geoip.dat https://github.com/v2ray/geoip/releases/latest/download/geoip.dat
|
||||||
|
|
||||||
|
VOLUME /etc/trojan-go
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
CMD [ "trojan-go", "-config", "/etc/trojan-go/config.json" ]
|
65
docker/trojan-go/README.md
Normal file
65
docker/trojan-go/README.md
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
## Trojan-Go Docker Image by Teddysun
|
||||||
|
|
||||||
|
[Trojan-Go][1] is An unidentifiable mechanism that helps you bypass [GFW](https://en.wikipedia.org/wiki/Great_Firewall).
|
||||||
|
|
||||||
|
Trojan-Go features multiple protocols over `TLS` to avoid both active/passive detections and ISP `QoS` limitations.
|
||||||
|
|
||||||
|
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/trojan-go
|
||||||
|
```
|
||||||
|
|
||||||
|
This pulls the latest release of trojan-go.
|
||||||
|
|
||||||
|
It can be found at [Docker Hub][4].
|
||||||
|
|
||||||
|
## Start a container
|
||||||
|
|
||||||
|
You **must create a configuration file** `/etc/trojan-go/config.json` in host at first:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mkdir -p /etc/trojan-go
|
||||||
|
```
|
||||||
|
|
||||||
|
A sample in JSON like below:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"run_type": "server",
|
||||||
|
"local_addr": "0.0.0.0",
|
||||||
|
"local_port": 443,
|
||||||
|
"remote_addr": "127.0.0.1",
|
||||||
|
"remote_port": 80,
|
||||||
|
"password": [
|
||||||
|
"your_awesome_password"
|
||||||
|
],
|
||||||
|
"ssl": {
|
||||||
|
"cert": "server.crt",
|
||||||
|
"key": "server.key",
|
||||||
|
"sni": "your-domain-name.com",
|
||||||
|
"fallback_port": 1234
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
An online documentation can be found [here](https://p4gefau1t.github.io/trojan-go/basic/config/)
|
||||||
|
|
||||||
|
There is an example to start a container that listen on port `443`, run as a Trojan server like below:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ docker run -d --network host --name trojan-go --restart=always -v /etc/trojan-go:/etc/trojan-go teddysun/trojan-go
|
||||||
|
```
|
||||||
|
|
||||||
|
[1]: https://github.com/p4gefau1t/trojan-go
|
||||||
|
[2]: https://docs.docker.com/
|
||||||
|
[3]: https://docs.docker.com/install/
|
||||||
|
[4]: https://hub.docker.com/r/teddysun/trojan-go/
|
45
docker/trojan-go/build_trojan-go.sh
Normal file
45
docker/trojan-go/build_trojan-go.sh
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# This is a Shell script for build multi-architectures trojan-go binary file
|
||||||
|
#
|
||||||
|
# Supported architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
|
||||||
|
#
|
||||||
|
# Copyright (C) 2020 Teddysun <i@teddysun.com>
|
||||||
|
#
|
||||||
|
# Reference URL:
|
||||||
|
# https://github.com/p4gefau1t/trojan-go
|
||||||
|
|
||||||
|
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/p4gefau1t/trojan-go.git
|
||||||
|
cd trojan-go || exit 2
|
||||||
|
go get -d -v
|
||||||
|
|
||||||
|
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 trojan-go_linux_${ARCH}${V}"
|
||||||
|
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${V} go build -v -tags "full" -ldflags "${LDFLAGS}" -o ${cur_dir}/trojan-go_linux_${ARCH}${V}
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "Building trojan-go_linux_${ARCH}"
|
||||||
|
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -tags "full" -ldflags "${LDFLAGS}" -o ${cur_dir}/trojan-go_linux_${ARCH}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
chmod +x ${cur_dir}/trojan-go_linux_*
|
||||||
|
# clean up
|
||||||
|
cd ${cur_dir} && rm -fr trojan-go
|
||||||
|
|
21
docker/trojan-go/config.json
Normal file
21
docker/trojan-go/config.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"run_type": "server",
|
||||||
|
"local_addr": "0.0.0.0",
|
||||||
|
"local_port": 443,
|
||||||
|
"remote_addr": "127.0.0.1",
|
||||||
|
"remote_port": 80,
|
||||||
|
"password": [
|
||||||
|
"your_password"
|
||||||
|
],
|
||||||
|
"ssl": {
|
||||||
|
"cert": "your_cert.crt",
|
||||||
|
"key": "your_key.key",
|
||||||
|
"sni": "your-domain-name.com"
|
||||||
|
},
|
||||||
|
"router":{
|
||||||
|
"enabled": true,
|
||||||
|
"block": [
|
||||||
|
"geoip:private"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
52
docker/trojan-go/trojan-go.sh
Normal file
52
docker/trojan-go/trojan-go.sh
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# This is a Shell script for trojan-go based alpine with Docker image
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019 - 2020 Teddysun <i@teddysun.com>
|
||||||
|
#
|
||||||
|
# Reference URL:
|
||||||
|
# https://github.com/p4gefau1t/trojan-go
|
||||||
|
|
||||||
|
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
|
||||||
|
TROJAN_FILE="trojan-go_linux_${ARCH}"
|
||||||
|
|
||||||
|
echo "Downloading binary file: ${TROJAN_FILE}"
|
||||||
|
wget -O /usr/bin/trojan-go https://dl.lamp.sh/files/${TROJAN_FILE} > /dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error: Failed to download binary file: ${TROJAN_FILE}" && exit 1
|
||||||
|
fi
|
||||||
|
echo "Download binary file: ${TROJAN_FILE} completed"
|
||||||
|
|
||||||
|
chmod +x /usr/bin/trojan-go
|
Loading…
x
Reference in New Issue
Block a user