2.0.0 init

Completely revamped the container to support the new external configuration files.
This commit is contained in:
PassiveLemon 2023-07-19 16:27:14 -04:00
parent 3fc92bac27
commit 5ece7c0da4
4 changed files with 87 additions and 31 deletions

View File

@ -1,19 +1,23 @@
FROM alpine:latest FROM alpine:latest
RUN apk update && apk upgrade &&\ RUN apk update && apk upgrade &&\
apk add bash curl jq sudo &&\ apk add bash curl jq git go sudo
mkdir -p /zoraxy/data/
VOLUME [ "/zoraxy/data/" ] RUN mkdir -p /zoraxy/source/ &&\
mkdir -p /zoraxy/config/
VOLUME [ "/zoraxy/config/" ]
COPY entrypoint.sh /zoraxy/ COPY entrypoint.sh /zoraxy/
COPY notifier.sh /zoraxy/
RUN chmod +x /zoraxy/entrypoint.sh RUN chmod 755 /zoraxy/ &&\
chmod +x /zoraxy/entrypoint.sh
ENV DOCKER="2.0.0"
ENV NOTIFS="1"
ENV VERSION="latest"
ENV ARGS="-port=:8000 -noauth=false" ENV ARGS="-port=:8000 -noauth=false"
EXPOSE 80 ENTRYPOINT ["/zoraxy/entrypoint.sh"]
EXPOSE 443
EXPOSE 8000
ENTRYPOINT ["/zoraxy/entrypoint.sh"]

View File

@ -25,9 +25,10 @@ services:
- 443:443 # Https port - 443:443 # Https port
- (external):8000 # Management portal port - (external):8000 # Management portal port
volumes: volumes:
- (path to storage directory):/zoraxy/data/ # Host directory for Zoraxy file storage - (path to storage directory):/zoraxy/config/ # Host directory for Zoraxy file storage
environment: environment:
ARGS: '(your arguments)' # The arguments to run with Zoraxy. Enter them as they would be entered normally. ARGS: '(your arguments)' # The arguments to run with Zoraxy. Enter them as they would be entered normally.
VERSION: '(version in x.x.x)' # The release version of Zoraxy.
``` ```
| Operator | Need | Details | | Operator | Need | Details |
@ -35,15 +36,15 @@ services:
| `-d` | Yes | will run the container in the background. | | `-d` | Yes | will run the container in the background. |
| `--name (container name)` | No | Sets the name of the container to the following word. You can change this to whatever you want. | | `--name (container name)` | No | Sets the name of the container to the following word. You can change this to whatever you want. |
| `-p (ports)` | Yes | Depending on how your network is setup, you may need to portforward 80, 443, and the management port. | | `-p (ports)` | Yes | Depending on how your network is setup, you may need to portforward 80, 443, and the management port. |
| `-v (path to storage directory):/zoraxy/data/` | Recommend | Sets the folder that holds your files. This should be the place you just chose. By default, it will create a Docker volume for the files for persistency but they will not be accessible. | | `-v (path to storage directory):/zoraxy/config/` | Recommend | Sets the folder that holds your files. This should be the place you just chose. By default, it will create a Docker volume for the files for persistency but they will not be accessible. |
| `-e ARGS=(your arguments)` | No | Sets the arguments to run Zoraxy with. Enter them as you would normally. By default, it is ran with `-port=:8000 -noauth=false` | | `-e ARGS=(your arguments)` | No | Sets the arguments to run Zoraxy with. Enter them as you would normally. By default, it is ran with `-port=:8000 -noauth=false` |
| `-e VERSION=(version)` | No | Sets the version of Zoraxy that the container will download. Must be a supported version found on the Zoraxy Github. Defaults to the latest if not set. | | `-e VERSION=(version)` | Recommended | Sets the version of Zoraxy that the container will download. Must be a supported release found on the Zoraxy GitHub. Defaults to the latest if not set. |
| `passivelemon/zoraxy-docker:latest` | Yes | The repository on Docker hub. By default, it is the latest version that I have published. | | `passivelemon/zoraxy-docker:latest` | Yes | The repository on Docker hub. By default, it is the latest version that I have published. |
## Examples: </br> ## Examples: </br>
### Docker Run </br> ### Docker Run </br>
``` ```
docker run -d --name zoraxy -p 80:80 -p 443:443 -p 8005:8000/tcp -v /home/docker/Containers/Zoraxy:/zoraxy/data/ -e ARGS="-port=:8000 -noauth=false" passivelemon/zoraxy-docker:latest docker run -d --name zoraxy -p 80:80 -p 443:443 -p 8005:8000/tcp -v /home/docker/Containers/Zoraxy:/zoraxy/config/ -e ARGS="-port=:8000 -noauth=false" passivelemon/zoraxy-docker:latest
``` ```
### Docker Compose </br> ### Docker Compose </br>
@ -58,12 +59,7 @@ services:
- 443:443 - 443:443
- 8005:8000/tcp - 8005:8000/tcp
volumes: volumes:
- /home/docker/Containers/Zoraxy:/zoraxy/data/ - /home/docker/Containers/Zoraxy:/zoraxy/config/
environment: environment:
ARGS: '-port=:8000 -noauth=false' ARGS: '-port=:8000 -noauth=false'
``` ```
### Other </br>
Currently, the internal management port can't be changed without building the image yourself. You can just change the container from `8000:8000` to `new:8000` and access the interface over the new port. </br>
If the container doesn't start properly, you might be rate limited from GitHub for some amount of time. You can check this by running `curl -s https://api.github.com/repos/tobychui/zoraxy/releases` on the host. If you are, you will just have to wait for a little while or use a VPN. </br>

View File

@ -1,20 +1,50 @@
#!/usr/bin/env bash #!/usr/bin/env bash
cd /zoraxy/data/ if [ "$(curl -s "https://api.github.com/repos/tobychui/zoraxy/git/refs/tags" | jq 'any(.[] | tostring; test("API rate limit exceeded"))')" = "true" ]; then
echo "|| Currently rate limited by GitHub. Please wait until it clears. ||"
exit
fi
if [ "$VERSION" != "" ]; then # Container update notifier
echo "|| Using release ${VERSION} ||" . /zoraxy/notifier.sh
release=${VERSION}
# Remove the V from the version if its present
VERSION=$(echo "${VERSION}" | awk '{gsub(/^v/, ""); print}')
# If version isn't valid, hard stop.
function versionvalidate () {
if [ -z $(curl -s "https://api.github.com/repos/tobychui/zoraxy/git/refs/tags" | jq -r ".[].ref | select(contains(\"${VERSION}\"))") ]; then
echo "|| ${VERSION} is not a valid version. Please ensure it is set correctly. ||"
exit
fi
}
# Version setting
if [ "${VERSION}" = "latest" ]; then
# Latest release
VERSION=$(curl -s https://api.github.com/repos/tobychui/zoraxy/releases | jq -r "[.[] | select(.tag_name)] | max_by(.created_at) | .tag_name")
versionvalidate
echo "|| Using Zoraxy version ${VERSION} (latest). ||"
else else
echo "|| Using latest release ||" versionvalidate
# Gets the latest pre-release version tag. Will be updated when official release comes out. echo "|| Using Zoraxy version ${VERSION}. ||"
release=$(curl -s https://api.github.com/repos/tobychui/zoraxy/releases | jq -r 'map(select(.prerelease)) | .[0].tag_name')
fi fi
if [ ! -e "/zoraxy/data/zoraxy_linux_amd64-${release}" ]; then # Downloads & setup
echo "|| Downloading version ${release} ||" if [ ! -f "/zoraxy/server/zoraxy_bin_${VERSION}" ]; then
curl -Lso /zoraxy/data/zoraxy_linux_amd64-${release} https://github.com/tobychui/zoraxy/releases/download/${release}/zoraxy_linux_amd64 echo "|| Cloning repository... ||"
chmod u+x /zoraxy/data/zoraxy_linux_amd64-${release} cd /zoraxy/source/
git clone --depth=1 --branch main https://github.com/tobychui/zoraxy
cd /zoraxy/source/zoraxy/src/
echo "|| Building... ||"
go mod tidy
go build
mkdir -p /usr/local/bin/
mv /zoraxy/source/zoraxy/src/zoraxy /usr/local/bin/zoraxy_bin_${VERSION}
chmod 755 /usr/local/bin/zoraxy_bin_${VERSION}
echo "|| Finished. ||"
fi fi
./zoraxy_linux_amd64-${release} ${ARGS} # Starting
cd /zoraxy/config/
zoraxy_bin_${VERSION} ${ARGS}

26
docker/notifier.sh Normal file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Container update notifier. Funny code do not go brrrrrrr
UPDATE=$(curl -s https://api.github.com/repos/PassiveLemon/zoraxy-docker/releases | jq -r 'map(select(.prerelease = false)) | .[0].tag_name')
UPDATE1=$(echo $UPDATE | awk -F. '{print $1}')
UPDATE2=$(echo $UPDATE | awk -F. '{print $2}')
UPDATE3=$(echo $UPDATE | awk -F. '{print $3}')
DOCKER1=$(echo $DOCKER | awk -F. '{print $1}')
DOCKER2=$(echo $DOCKER | awk -F. '{print $2}')
DOCKER3=$(echo $DOCKER | awk -F. '{print $3}')
NOTIFY=0
if [ "${DOCKER1}" -lt "${UPDATE1}" ]; then
NOTIFY=1
fi
if [ "${DOCKER1}" -le "${UPDATE1}" ] && [ "${DOCKER2}" -lt "${UPDATE2}" ]; then
NOTIFY=1
fi
if [ "${DOCKER1}" -le "${UPDATE1}" ] && [ "${DOCKER2}" -le "${UPDATE2}" ] && [ "${DOCKER3}" -lt "${UPDATE3}" ]; then
NOTIFY=1
fi
if [ "${NOTIFY}" = "1" ] && [ "${NOTIFS}" != "0" ]; then
echo "|| Container update available. Current (${DOCKER}): New (${UPDATE}). ||"
fi