mirror of
https://github.com/teddysun/across.git
synced 2025-01-18 22:09:35 +08:00
Added hysteria Docker Image
This commit is contained in:
parent
b31390e228
commit
e1acb61301
23
docker/hysteria/Dockerfile.architecture
Normal file
23
docker/hysteria/Dockerfile.architecture
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Dockerfile for hysteria based alpine
|
||||||
|
# Copyright (C) 2022 Teddysun <i@teddysun.com>
|
||||||
|
# Reference URL:
|
||||||
|
# https://github.com/HyNetwork/hysteria
|
||||||
|
|
||||||
|
FROM --platform=${TARGETPLATFORM} alpine:latest
|
||||||
|
LABEL maintainer="Teddysun <i@teddysun.com>"
|
||||||
|
|
||||||
|
ARG TARGETPLATFORM
|
||||||
|
WORKDIR /root
|
||||||
|
COPY hysteria.sh /root/hysteria.sh
|
||||||
|
COPY server.json /etc/hysteria/server.json
|
||||||
|
COPY cert.crt /etc/hysteria/cert.crt
|
||||||
|
COPY private.key /etc/hysteria/private.key
|
||||||
|
RUN set -ex \
|
||||||
|
&& apk add --no-cache bash tzdata ca-certificates \
|
||||||
|
&& chmod +x /root/hysteria.sh \
|
||||||
|
&& /root/hysteria.sh "${TARGETPLATFORM}" \
|
||||||
|
&& rm -fv /root/hysteria.sh
|
||||||
|
|
||||||
|
VOLUME /etc/hysteria
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
CMD [ "/usr/bin/hysteria", "server", "--config", "/etc/hysteria/server.json" ]
|
53
docker/hysteria/README.md
Normal file
53
docker/hysteria/README.md
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
## Hysteria Docker Image by Teddysun
|
||||||
|
|
||||||
|
[Hysteria][1] is a feature-packed proxy & relay utility optimized for lossy, unstable connections, powered by a customized QUIC protocol.
|
||||||
|
|
||||||
|
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/hysteria
|
||||||
|
```
|
||||||
|
|
||||||
|
This pulls the latest release of Hysteria.
|
||||||
|
|
||||||
|
It can be found at [Docker Hub][4].
|
||||||
|
|
||||||
|
## Start a container
|
||||||
|
|
||||||
|
You **must create a configuration file** `/etc/hysteria/server.json` in host at first:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mkdir -p /etc/hysteria
|
||||||
|
```
|
||||||
|
|
||||||
|
A sample in JSON like below:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"listen": ":8998",
|
||||||
|
"cert": "/etc/hysteria/cert.crt",
|
||||||
|
"key": "/root/hysteria/private.key",
|
||||||
|
"obfs": "dGVkZHlzdW4uY29tCg=="
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
There is an example to start a container that listen on port `8998`, run as a Hysteria server like below:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ docker run -d -p 8998:8998 --name hysteria --restart=always -v /etc/hysteria:/etc/hysteria teddysun/hysteria
|
||||||
|
```
|
||||||
|
|
||||||
|
**Warning**: The port number must be same as configuration and opened in firewall.
|
||||||
|
|
||||||
|
[1]: https://github.com/HyNetwork/hysteria
|
||||||
|
[2]: https://docs.docker.com/
|
||||||
|
[3]: https://docs.docker.com/install/
|
||||||
|
[4]: https://hub.docker.com/r/teddysun/hysteria/
|
54
docker/hysteria/build_hysteria.sh
Normal file
54
docker/hysteria/build_hysteria.sh
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# This is a Shell script for build multi-architectures hysteria binary file
|
||||||
|
#
|
||||||
|
# Supported architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
|
||||||
|
#
|
||||||
|
# Copyright (C) 2022 Teddysun <i@teddysun.com>
|
||||||
|
#
|
||||||
|
# Reference URL:
|
||||||
|
# https://github.com/HyNetwork/hysteria
|
||||||
|
|
||||||
|
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}
|
||||||
|
echo "git clone https://github.com/HyNetwork/hysteria.git"
|
||||||
|
git clone https://github.com/HyNetwork/hysteria.git
|
||||||
|
cd hysteria || exit 2
|
||||||
|
|
||||||
|
VERSION="$(git describe)"
|
||||||
|
COMMIT="$(git rev-parse HEAD)"
|
||||||
|
TIMESTAMP="$(date "+%F")"
|
||||||
|
|
||||||
|
LDFLAGS="-s -w -X 'main.appVersion=${VERSION}' -X 'main.appCommit=${COMMIT}' -X 'main.appDate=${TIMESTAMP}' -buildid="
|
||||||
|
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 hysteria_linux_${ARCH}${V}"
|
||||||
|
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${V} go build -v -trimpath -ldflags "${LDFLAGS}" -o ${cur_dir}/hysteria_linux_${ARCH}${V} ./cmd || exit 1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "Building hysteria_linux_${ARCH}"
|
||||||
|
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -trimpath -ldflags "${LDFLAGS}" -o ${cur_dir}/hysteria_linux_${ARCH} ./cmd || exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
ARCHS=( 386 amd64 )
|
||||||
|
for ARCH in ${ARCHS[@]}; do
|
||||||
|
echo "Building hysteria_windows_${ARCH}.exe"
|
||||||
|
env CGO_ENABLED=0 GOOS=windows GOARCH=${ARCH} go build -v -trimpath -ldflags "${LDFLAGS}" -o ${cur_dir}/hysteria_windows_${ARCH}.exe ./cmd
|
||||||
|
done
|
||||||
|
|
||||||
|
chmod +x ${cur_dir}/hysteria_*
|
||||||
|
# clean up
|
||||||
|
cd ${cur_dir} && rm -fr hysteria
|
11
docker/hysteria/cert.crt
Normal file
11
docker/hysteria/cert.crt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIBhzCCAS2gAwIBAgIUdeX0JHrXkaZmqP1Mz3Zf2G/jpSYwCgYIKoZIzj0EAwIw
|
||||||
|
GDEWMBQGA1UEAwwNd3d3LmJhaWR1LmNvbTAgFw0yMjA2MjIxMTA0NDRaGA8yMTIy
|
||||||
|
MDUyOTExMDQ0NFowGDEWMBQGA1UEAwwNd3d3LmJhaWR1LmNvbTBZMBMGByqGSM49
|
||||||
|
AgEGCCqGSM49AwEHA0IABFrHHjYyV1qmM1JqCpSWyjpDUbHPE8q9a/qJaM/CRgxI
|
||||||
|
nqHHlxP/jobvBE4cCrh6oaSZ1xsC4GzsPJ/mOTFbWnGjUzBRMB0GA1UdDgQWBBSX
|
||||||
|
JHqdgl1xasGZL4G3dpIaqjBCBzAfBgNVHSMEGDAWgBSXJHqdgl1xasGZL4G3dpIa
|
||||||
|
qjBCBzAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMCA0gAMEUCIQCkJlvygG51
|
||||||
|
DbKUFvlRofEkTa/wxKb5VdTMSM9mtl5erAIgTnExoE8QExf+Bo3Vp24Nhc3JXG8P
|
||||||
|
UyovWYeLSyooH/s=
|
||||||
|
-----END CERTIFICATE-----
|
13
docker/hysteria/client.json
Normal file
13
docker/hysteria/client.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"server": "IP:8998",
|
||||||
|
"obfs": "dGVkZHlzdW4uY29tCg==",
|
||||||
|
"up_mbps": 200,
|
||||||
|
"down_mbps": 1000,
|
||||||
|
"insecure": true,
|
||||||
|
"socks5": {
|
||||||
|
"listen": "127.0.0.1:1080"
|
||||||
|
},
|
||||||
|
"http": {
|
||||||
|
"listen": "127.0.0.1:1081"
|
||||||
|
}
|
||||||
|
}
|
51
docker/hysteria/hysteria.sh
Normal file
51
docker/hysteria/hysteria.sh
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# This is a Shell script for hysteria based alpine with Docker image
|
||||||
|
#
|
||||||
|
# Copyright (C) 2022 Teddysun <i@teddysun.com>
|
||||||
|
#
|
||||||
|
# Reference URL:
|
||||||
|
# https://github.com/HyNetwork/hysteria
|
||||||
|
|
||||||
|
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
|
||||||
|
HYSTERIA_FILE="hysteria_linux_${ARCH}"
|
||||||
|
|
||||||
|
echo "Downloading binary file: ${HYSTERIA_FILE}"
|
||||||
|
wget -O /usr/bin/hysteria https://dl.lamp.sh/files/${HYSTERIA_FILE} > /dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error: Failed to download binary file: ${HYSTERIA_FILE}" && exit 1
|
||||||
|
fi
|
||||||
|
echo "Download binary file: ${HYSTERIA_FILE} completed"
|
||||||
|
chmod +x /usr/bin/hysteria
|
8
docker/hysteria/private.key
Normal file
8
docker/hysteria/private.key
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
-----BEGIN EC PARAMETERS-----
|
||||||
|
BggqhkjOPQMBBw==
|
||||||
|
-----END EC PARAMETERS-----
|
||||||
|
-----BEGIN EC PRIVATE KEY-----
|
||||||
|
MHcCAQEEID1ebxNPwh/nuBj/QqFSg36K75lS0E+iMaPUkaa1J/JRoAoGCCqGSM49
|
||||||
|
AwEHoUQDQgAEWsceNjJXWqYzUmoKlJbKOkNRsc8Tyr1r+oloz8JGDEieoceXE/+O
|
||||||
|
hu8EThwKuHqhpJnXGwLgbOw8n+Y5MVtacQ==
|
||||||
|
-----END EC PRIVATE KEY-----
|
6
docker/hysteria/server.json
Normal file
6
docker/hysteria/server.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"listen": ":8998",
|
||||||
|
"cert": "/etc/hysteria/cert.crt",
|
||||||
|
"key": "/root/hysteria/private.key",
|
||||||
|
"obfs": "dGVkZHlzdW4uY29tCg=="
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user