Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

Commit

Permalink
2.0.0 init
Browse files Browse the repository at this point in the history
Completely revamped the container to support the new external configuration files
  • Loading branch information
PassiveLemon committed Jul 19, 2023
1 parent 4dee71c commit 8409bc5
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 37 deletions.
20 changes: 13 additions & 7 deletions Dockerfile
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
FROM alpine:latest

RUN apk update && apk upgrade &&\
apk add bash curl jq &&\
mkdir -p /zoraxy/data/
apk add bash curl jq git go sudo

VOLUME [ "/zoraxy/data/" ]
RUN mkdir -p /zoraxy/source/ &&\
mkdir -p /zoraxy/config/

VOLUME [ "/zoraxy/config/" ]

COPY entrypoint.sh /zoraxy/
COPY notifier.sh /zoraxy/

RUN chmod +x /zoraxy/entrypoint.sh
RUN chmod 755 /zoraxy/ &&\
chmod +x /zoraxy/entrypoint.sh

ENV ARGS="-port=:8000 -noauth=false"
ENV DOCKER="2.0.0"
ENV NOTIFS="1"

EXPOSE 8000
ENV VERSION="latest"
ENV ARGS="-port=:8000 -noauth=false"

ENTRYPOINT ["/zoraxy/entrypoint.sh"]
ENTRYPOINT ["/zoraxy/entrypoint.sh"]
Empty file modified LICENSE
100755 → 100644
Empty file.
37 changes: 19 additions & 18 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# [zoraxy-docker](https://github.com/tobychui/zoraxy/tree/main/docker) </br>
# [zoraxy-docker](https://github.com/tobychui/zoraxy/) </br>

[![Repo](https://img.shields.io/badge/Docker-Repo-007EC6?labelColor-555555&color-007EC6&logo=docker&logoColor=fff&style=flat-square)](https://hub.docker.com/r/passivelemon/zoraxy-docker)
[![Version](https://img.shields.io/docker/v/passivelemon/zoraxy-docker/latest?labelColor-555555&color-007EC6&style=flat-square)](https://hub.docker.com/r/passivelemon/zoraxy-docker)
[![Size](https://img.shields.io/docker/image-size/passivelemon/zoraxy-docker/latest?sort=semver&labelColor-555555&color-007EC6&style=flat-square)](https://hub.docker.com/r/passivelemon/zoraxy-docker)
[![Pulls](https://img.shields.io/docker/pulls/passivelemon/zoraxy-docker?labelColor-555555&color-007EC6&style=flat-square)](https://hub.docker.com/r/passivelemon/zoraxy-docker)

# Update:
<b>This will be continued in the official Zoraxy repository. Go there for the latest updates. This repository is here for archival purposes and may become outdated. </b>

Docker container for [Zoraxy](https://github.com/tobychui/zoraxy) </br>

## Setup: </br>
There really isn't much here, just make sure you find a good place to store the files on your host. The container will download everything automatically so this place is used to store the files so they aren't deleted when the container is deleted. </br>
Although not required, it is recommended to give Zoraxy a dedicated location on the host to mount the container. That way, the host/user can access them whenever needed. A volume will be created automatically within Docker if a location is not specified. </br>

You may also need to portforward your 80/443 to allow http and https traffic. If you are accessing the interface from outside of the local network, you may also need to forward your management port. If you know how to do this, great! If not, find the manufacturer of your router and search on how to do that. There are too many to be listed here. </br>

### Using Docker run </br>
```
Expand All @@ -28,26 +25,28 @@ services:
ports:
- 80:80 # Http port
- 443:443 # Https port
- (wanted port):8000 # Management portal port
- (external):8000 # Management portal port
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:
ARGS: '-port=:8000' # Telling Zoraxy what port to listen on for the management portal. Changing this means building the image yourself with your own exposed port. Might change in the future.
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 |
|:-|:-|:-|
| `-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. |
| `-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. |
| `-e ARGS=(your arguments)` | No | Sets the arguments to run Zoraxy with. 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. |
| `-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/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 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. |

## Examples: </br>
### Docker Run </br>
```
docker run -d --name zoraxy -p 8000: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>
Expand All @@ -60,12 +59,14 @@ services:
ports:
- 80:80
- 443:443
- 8000:8000
- 8005:8000/tcp
volumes:
- /home/docker/Containers/Zoraxy:/zoraxy/data/
- /home/docker/Containers/Zoraxy:/zoraxy/config/
environment:
ARGS: '-port=:8000'
ARGS: '-port=:8000 -noauth=false'
```

### Other </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>
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 you get a jq syntax error, you might be IP rate limited by GitHub. Try running `curl -s https://api.github.com/repos/tModLoader/tModLoader/releases` on the server host and check the message. </br>
54 changes: 42 additions & 12 deletions entrypoint.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,20 +1,50 @@
#!/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

# Container update notifier
. /zoraxy/notifier.sh

# 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
}

if [ "$VERSION" != "" ]; then
echo "|| Using release ${VERSION} ||"
release=${VERSION}
# 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
echo "|| Using latest release ||"
# Gets the latest pre-release version tag.
release=$(curl -s https://api.github.com/repos/tobychui/zoraxy/releases | jq -r 'map(select(.prerelease)) | .[0].tag_name')
versionvalidate
echo "|| Using Zoraxy version ${VERSION}. ||"
fi

if [ ! -e /zoraxy/data/zoraxy_linux_amd64 ]; then
echo "|| Downloading version ${release} ||"
curl -sL --output /zoraxy/data/zoraxy_linux_amd64 https://github.com/tobychui/zoraxy/releases/download/${release}/zoraxy_linux_amd64
chmod u+x /zoraxy/data/zoraxy_linux_amd64
# Downloads & setup
if [ ! -f "/zoraxy/server/zoraxy_bin_${VERSION}" ]; then
echo "|| Cloning repository... ||"
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

./zoraxy_linux_amd64 ${ARGS}
# Starting
cd /zoraxy/config/
zoraxy_bin_${VERSION} ${ARGS}
26 changes: 26 additions & 0 deletions notifier.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8409bc5

Please sign in to comment.