This repository has been archived by the owner on Aug 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Completely revamped the container to support the new external configuration files
- Loading branch information
1 parent
4dee71c
commit 8409bc5
Showing
5 changed files
with
100 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |