Refactor Dockerfile

Switch to Alpine + compat and download zoraxy_plugin from the plugins repository
This commit is contained in:
PassiveLemon 2025-04-06 15:25:21 -04:00
parent f245a61d32
commit cc6501db12
4 changed files with 43 additions and 15 deletions

View File

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

View File

@ -1,5 +1,5 @@
## Build Zoraxy
FROM docker.io/golang:bookworm AS build-zoraxy
FROM docker.io/golang:alpine AS build-zoraxy
RUN mkdir -p /opt/zoraxy/source/ &&\
mkdir -p /usr/local/bin/
@ -15,37 +15,52 @@ RUN go mod tidy &&\
## 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/ &&\
mkdir -p /usr/local/bin/
WORKDIR /opt/zerotier/source/
RUN apt-get update -y &&\
apt-get install -y curl jq build-essential pkg-config clang cargo libssl-dev
RUN apk add --update --no-cache curl make gcc g++ linux-headers openssl-dev nano
RUN curl -Lo ZeroTierOne.tar.gz https://codeload.github.com/zerotier/ZeroTierOne/tar.gz/refs/tags/1.10.6 &&\
tar -xzvf ZeroTierOne.tar.gz &&\
cd ZeroTierOne-* &&\
make &&\
cd ZeroTierOne-*/zeroidc &&\
cargo update -p getrandom &&\
cd .. &&\
make -f make-linux.mk &&\
mv ./zerotier-one /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
COPY --chmod=700 ./entrypoint.sh /opt/zoraxy/
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-zoraxy /usr/local/bin/zoraxy /usr/local/bin/zoraxy
RUN apt-get update -y &&\
apt-get install -y bash sudo netcat-openbsd libssl-dev ca-certificates openssh-server
RUN mkdir -p /opt/zoraxy/plugin/
RUN apk add --update --no-cache bash sudo netcat-openbsd libressl-dev openssh ca-certificates libc6-compat libstdc++ &&\
mkdir -p /opt/zoraxy/plugin/ &&\
echo "tun" | tee -a /etc/modules
WORKDIR /opt/zoraxy/config/

View File

@ -95,6 +95,20 @@ Variables are the same as those in [Start Parameters](https://github.com/tobychu
> [!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.
### 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
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..."
for dir in "$1"/*; do