Merge pull request #628 from PassiveLemon/docker-plugins

Refactor Dockerfile
This commit is contained in:
Toby Chui 2025-05-04 11:27:31 +08:00 committed by GitHub
commit 7426cc2bb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 43 additions and 15 deletions

View File

@ -31,8 +31,7 @@ jobs:
- name: Setup building file structure - name: Setup building file structure
run: | run: |
cp -lr $GITHUB_WORKSPACE/src/ $GITHUB_WORKSPACE/docker/ cp -lr $GITHUB_WORKSPACE/src/ $GITHUB_WORKSPACE/docker/src/
cp -lr $GITHUB_WORKSPACE/example/ $GITHUB_WORKSPACE/docker/
- name: Build and push Docker image - name: Build and push Docker image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6

View File

@ -1,5 +1,5 @@
## Build Zoraxy ## Build Zoraxy
FROM docker.io/golang:bookworm AS build-zoraxy FROM docker.io/golang:alpine AS build-zoraxy
RUN mkdir -p /opt/zoraxy/source/ &&\ RUN mkdir -p /opt/zoraxy/source/ &&\
mkdir -p /usr/local/bin/ mkdir -p /usr/local/bin/
@ -15,39 +15,54 @@ RUN go mod tidy &&\
## Build ZeroTier ## Build ZeroTier
FROM docker.io/golang:bookworm AS build-zerotier FROM docker.io/rust:1.79-alpine AS build-zerotier
RUN mkdir -p /opt/zerotier/source/ &&\ RUN mkdir -p /opt/zerotier/source/ &&\
mkdir -p /usr/local/bin/ mkdir -p /usr/local/bin/
WORKDIR /opt/zerotier/source/ WORKDIR /opt/zerotier/source/
RUN apt-get update -y &&\ RUN apk add --update --no-cache curl make gcc g++ linux-headers openssl-dev nano
apt-get install -y curl jq build-essential pkg-config clang cargo libssl-dev
RUN curl -Lo ZeroTierOne.tar.gz https://codeload.github.com/zerotier/ZeroTierOne/tar.gz/refs/tags/1.10.6 &&\ RUN curl -Lo ZeroTierOne.tar.gz https://codeload.github.com/zerotier/ZeroTierOne/tar.gz/refs/tags/1.10.6 &&\
tar -xzvf ZeroTierOne.tar.gz &&\ tar -xzvf ZeroTierOne.tar.gz &&\
cd ZeroTierOne-* &&\ cd ZeroTierOne-*/zeroidc &&\
make &&\ cargo update -p getrandom &&\
cd .. &&\
make -f make-linux.mk &&\
mv ./zerotier-one /usr/local/bin/zerotier-one &&\ mv ./zerotier-one /usr/local/bin/zerotier-one &&\
chmod 755 /usr/local/bin/zerotier-one chmod 755 /usr/local/bin/zerotier-one
FROM docker.io/golang:bookworm ## Fetch plugin
FROM docker.io/golang:alpine AS fetch-plugin
RUN mkdir -p /opt/zoraxy/zoraxy_plugin/
RUN apk add --update --no-cache git
WORKDIR /opt/zoraxy/
RUN git clone https://github.com/aroz-online/zoraxy-official-plugins &&\
cp -r ./zoraxy-official-plugins/src/ztnc/mod/zoraxy_plugin/ /opt/zoraxy/zoraxy_plugin/
## Main
FROM docker.io/golang:alpine
# If you build it yourself, you will need to add the example directory into the docker directory. # If you build it yourself, you will need to add the example directory into the docker directory.
COPY --chmod=700 ./entrypoint.sh /opt/zoraxy/ COPY --chmod=700 ./entrypoint.sh /opt/zoraxy/
COPY --chmod=700 ./build_plugins.sh /usr/local/bin/build_plugins COPY --chmod=700 ./build_plugins.sh /usr/local/bin/build_plugins
COPY --chmod=700 ./example/plugins/ztnc/mod/zoraxy_plugin/ /opt/zoraxy/zoraxy_plugin/
COPY --from=fetch-plugin --chmod=700 /opt/zoraxy/zoraxy_plugin/ /opt/zoraxy/zoraxy_plugin/
COPY --from=build-zerotier /usr/local/bin/zerotier-one /usr/local/bin/zerotier-one COPY --from=build-zerotier /usr/local/bin/zerotier-one /usr/local/bin/zerotier-one
COPY --from=build-zoraxy /usr/local/bin/zoraxy /usr/local/bin/zoraxy COPY --from=build-zoraxy /usr/local/bin/zoraxy /usr/local/bin/zoraxy
RUN apt-get update -y &&\ RUN apk add --update --no-cache bash sudo netcat-openbsd libressl-dev openssh ca-certificates libc6-compat libstdc++ &&\
apt-get install -y bash sudo netcat-openbsd libssl-dev ca-certificates openssh-server mkdir -p /opt/zoraxy/plugin/ &&\
echo "tun" | tee -a /etc/modules
RUN mkdir -p /opt/zoraxy/plugin/
WORKDIR /opt/zoraxy/config/ WORKDIR /opt/zoraxy/config/

View File

@ -103,6 +103,20 @@ Variables are the same as those in [Start Parameters](https://github.com/tobychu
> [!IMPORTANT] > [!IMPORTANT]
> Contrary to the Zoraxy README, Docker usage of the port flag should NOT include the colon. Ex: `-e PORT="8000"` for Docker run and `PORT: "8000"` for Docker compose. > Contrary to the Zoraxy README, Docker usage of the port flag should NOT include the colon. Ex: `-e PORT="8000"` for Docker run and `PORT: "8000"` for Docker compose.
### ZeroTier
If you are running with ZeroTier, make sure to add the following flags to ensure ZeroTier functionality:
`--cap_add NET_ADMIN` and `--device /dev/net/tun:/dev/net/tun`
Or for Docker Compose:
```
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun:/dev/net/tun
```
### Plugins ### Plugins
You can find official plugins at https://github.com/aroz-online/zoraxy-official-plugins You can find official plugins at https://github.com/aroz-online/zoraxy-official-plugins

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
echo "Copying zoraxy_plugin to all mods..." echo "Copying zoraxy_plugin to all mods..."
for dir in "$1"/*; do for dir in "$1"/*; do