From 16a5191d2ccd757d2bb69e4692790bd037ed4b4f Mon Sep 17 00:00:00 2001 From: Hiddify Date: Thu, 14 Mar 2024 23:44:36 +0100 Subject: [PATCH] refactor docker --- Dockerfile | 17 ------ Makefile | 2 + config/option.go | 2 +- docker/Dockerfile | 25 +++++++++ docker/docker-compose.yml | 14 +++++ hiddify.json => docker/hiddify.json | 80 ++++++++++++++--------------- docker/hiddify.sh | 6 +++ hiddify.sh | 2 - 8 files changed, 88 insertions(+), 60 deletions(-) delete mode 100644 Dockerfile create mode 100644 docker/Dockerfile create mode 100644 docker/docker-compose.yml rename hiddify.json => docker/hiddify.json (96%) create mode 100644 docker/hiddify.sh delete mode 100644 hiddify.sh diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 0f73b9a..0000000 --- a/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM alpine:latest -ENV CONFIG='https://raw.githubusercontent.com/ircfspace/warpsub/main/export/warp#WARP%20(IRCF)' -ENV VERSION=v0.17.8 -WORKDIR /opt -RUN apk add wget tar gzip libc6-compat -RUN export ARCH=$(apk --print-arch) && if [ "$ARCH" = "i386" ]; then ARCH="386"; elif [ "$ARCH" = "x86_64" ]; then ARCH="amd64"; fi && wget https://github.com/hiddify/hiddify-next-core/releases/download/${VERSION}/hiddify-cli-linux-$ARCH.tar.gz -O hiddify-cli.tar.gz -RUN tar -xzf hiddify-cli.tar.gz && rm hiddify-cli.tar.gz -COPY hiddify.sh . -COPY hiddify.json . -RUN chmod +x hiddify.sh - -EXPOSE 2334 -EXPOSE 6756 -EXPOSE 6450 - - -ENTRYPOINT [ "/opt/hiddify.sh" ] \ No newline at end of file diff --git a/Makefile b/Makefile index 9c4b26c..fb0482a 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +.ONESHELL: PRODUCT_NAME=libcore BASENAME=$(PRODUCT_NAME) BINDIR=bin @@ -105,6 +106,7 @@ release: # Create a new tag for release. echo "version: $${VERSION_STR}+$${BUILD_NUMBER}" && \ sed -i -e "s|CFBundleVersion\s*[^<]*|CFBundleVersion$${VERSION_STR}|" Info.plist &&\ sed -i -e "s|CFBundleShortVersionString\s*[^<]*|CFBundleShortVersionString$${VERSION_STR}|" Info.plist &&\ + sed -i "s|ENV VERSION=.*|ENV VERSION=v$${TAG}|g" docker/Dockerfile && \ git add Info.plist && \ git commit -m "release: version $${TAG}" && \ echo "creating git tag : v$${TAG}" && \ diff --git a/config/option.go b/config/option.go index eb9501f..6479d52 100644 --- a/config/option.go +++ b/config/option.go @@ -97,7 +97,7 @@ func DefaultConfigOptions() *ConfigOptions { }, InboundOptions: InboundOptions{ EnableTun: false, - SetSystemProxy: true, + SetSystemProxy: false, MixedPort: 2334, LocalDnsPort: 16450, MTU: 9000, diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..6a9ba52 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,25 @@ +FROM alpine:latest +ENV CONFIG='https://raw.githubusercontent.com/ircfspace/warpsub/main/export/warp#WARP%20(IRCF)' +ENV VERSION=0.17.8 +WORKDIR /hiddify +RUN apk add wget tar gzip libc6-compat + +RUN case "$(apk --print-arch)" in \ + x86_64) ARCH=amd64 ;; \ + i386) ARCH=386 ;; \ + armv7l) ARCH=arm ;; \ + aarch64) ARCH=arm64 ;; \ + *) echo "Unsupported architecture: $(apk --print-arch) $(uname -m)" && exit 1 ;; \ + esac && \ + curl -l -o hiddify-cli.tar.gz https://github.com/hiddify/hiddify-next-core/releases/download/${VERSION}/hiddify-cli-linux-$ARCH.tar.gz && \ + tar -xzf hiddify-cli.tar.gz && rm hiddify-cli.tar.gz +COPY hiddify.sh . +RUN chmod +x hiddify.sh +COPY hiddify.json ./data/ + +EXPOSE 2334 +EXPOSE 6756 +EXPOSE 6450 + + +ENTRYPOINT [ "/opt/hiddify.sh" ] \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..1d22406 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + hiddify: + image: ghcr.io/hiddify/hiddify-next-core/cli:latest + ports: + - "2334:2334" + - "6756:6756" + - "6450:6450" + environment: + CONFIG: "https://raw.githubusercontent.com/ircfspace/warpsub/main/export/warp#WARP%20(IRCF)" + volumes: + - ./data/:/hiddify/data/ + command: ["/opt/hiddify.sh"] diff --git a/hiddify.json b/docker/hiddify.json similarity index 96% rename from hiddify.json rename to docker/hiddify.json index 48a7172..5b15072 100644 --- a/hiddify.json +++ b/docker/hiddify.json @@ -1,41 +1,41 @@ -{ - "service-mode": "proxy", - "log-level": "info", - "resolve-destination": true, - "ipv6-mode": "prefer_ipv4", - "remote-dns-address": "tcp://1.1.1.1", - "remote-dns-domain-strategy": "", - "direct-dns-address": "1.1.1.1", - "direct-dns-domain-strategy": "", - "mixed-port": 2334, - "local-dns-port": 6450, - "tun-implementation": "mixed", - "mtu": 9000, - "strict-route": false, - "connection-test-url": "https://www.gstatic.com/generate_204", - "url-test-interval": 600, - "enable-clash-api": true, - "clash-api-port": 6756, - "bypass-lan": false, - "allow-connection-from-lan": true, - "enable-fake-dns": false, - "enable-dns-routing": true, - "independent-dns-cache": true, - "enable-tls-fragment": false, - "tls-fragment-size": "20-70", - "tls-fragment-sleep": "10-30", - "enable-tls-mixed-sni-case": false, - "enable-tls-padding": false, - "tls-padding-size": "15-30", - "enable-mux": false, - "mux-padding": false, - "mux-max-streams": 4, - "mux-protocol": "h2mux", - "enable-warp": false, - "warp-detour-mode": "outbound", - "warp-license-key": "", - "warp-clean-ip": "auto", - "warp-port": 0, - "warp-noise": "5-10", - "warp-noise-delay": "20-200" +{ + "service-mode": "proxy", + "log-level": "info", + "resolve-destination": true, + "ipv6-mode": "prefer_ipv4", + "remote-dns-address": "tcp://1.1.1.1", + "remote-dns-domain-strategy": "", + "direct-dns-address": "1.1.1.1", + "direct-dns-domain-strategy": "", + "mixed-port": 2334, + "local-dns-port": 6450, + "tun-implementation": "mixed", + "mtu": 9000, + "strict-route": false, + "connection-test-url": "https://www.gstatic.com/generate_204", + "url-test-interval": 600, + "enable-clash-api": true, + "clash-api-port": 6756, + "bypass-lan": false, + "allow-connection-from-lan": true, + "enable-fake-dns": false, + "enable-dns-routing": true, + "independent-dns-cache": true, + "enable-tls-fragment": false, + "tls-fragment-size": "20-70", + "tls-fragment-sleep": "10-30", + "enable-tls-mixed-sni-case": false, + "enable-tls-padding": false, + "tls-padding-size": "15-30", + "enable-mux": false, + "mux-padding": false, + "mux-max-streams": 4, + "mux-protocol": "h2mux", + "enable-warp": false, + "warp-detour-mode": "outbound", + "warp-license-key": "", + "warp-clean-ip": "auto", + "warp-port": 0, + "warp-noise": "5-10", + "warp-noise-delay": "20-200" } \ No newline at end of file diff --git a/docker/hiddify.sh b/docker/hiddify.sh new file mode 100644 index 0000000..150b491 --- /dev/null +++ b/docker/hiddify.sh @@ -0,0 +1,6 @@ +#!/bin/sh +if [ -f "/opt/hiddify.json" ]; then + /hiddify/HiddifyCli run --config "$CONFIG" -h /hiddify/data/hiddify.json +else + /hiddify/HiddifyCli run --config "$CONFIG" +fi diff --git a/hiddify.sh b/hiddify.sh deleted file mode 100644 index 4f70655..0000000 --- a/hiddify.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -/opt/HiddifyCli run --config $CONFIG -h /opt/hiddify.json