diff --git a/Dockerfile b/Dockerfile index fdd0aa9..13e8d73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,9 @@ RUN easy-add --file entrypoint-demoter --from https://github.com/itzg/entrypoint ARG SET_PROPERTY_VERSION=0.1.1 RUN easy-add --file set-property --from https://github.com/itzg/set-property/releases/download/${SET_PROPERTY_VERSION}/set-property_${SET_PROPERTY_VERSION}_linux_${ARCH}.tar.gz +ARG RESTIFY_VERSION=1.2.0 +RUN easy-add --file restify --from https://github.com/itzg/restify/releases/download/${RESTIFY_VERSION}/restify_${RESTIFY_VERSION}_linux_amd64.tar.gz + COPY *.sh /opt/ COPY property-definitions.json /etc/bds-property-definitions.json @@ -34,4 +37,4 @@ COPY property-definitions.json /etc/bds-property-definitions.json # Available versions listed at # https://minecraft.gamepedia.com/Bedrock_Edition_1.11.0 # https://minecraft.gamepedia.com/Bedrock_Edition_1.12.0 -ENV VERSION=1.12 +ENV VERSION=LATEST diff --git a/README.md b/README.md index ab01442..69c53d9 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,11 @@ For Minecraft Java Edition you'll need to use this image instead: - `EULA` (no default) : must be set to `TRUE` to accept the [Minecraft End User License Agreement](https://minecraft.net/terms) -- `VERSION` (1.12) : can be set to a specific server version or just 1.11 or 1.12 to pick - the latest known version of each +- `VERSION` (`LATEST`) : can be set to a specific server version or the following special values can be used: + - `LATEST` : determines the latest version and can be used to auto-upgrade on container start + - `PREVIOUS` : uses the previously maintained major version. Useful when the mobile app is gradually being upgraded across devices + - `1.11` : the latest version of 1.11 + - `1.12` : the latest version of 1.12 - `UID` (default derived from `/data` owner) : can be set to a specific user ID to run the bedrock server process - `GID` (default derived from `/data` owner) : can be set to a specific group ID to run the diff --git a/bedrock-entry.sh b/bedrock-entry.sh index de66817..2db20ae 100755 --- a/bedrock-entry.sh +++ b/bedrock-entry.sh @@ -11,21 +11,32 @@ fi set -e case ${VERSION} in - 1.11) + 1.11|PREVIOUS) VERSION=1.11.4.2 ;; 1.12) VERSION=1.12.0.28 ;; + *) + DOWNLOAD_URL=$(restify --attribute=data-platform=serverBedrockLinux https://www.minecraft.net/en-us/download/server/bedrock/ | jq -r '.[0].href') + if [[ ${DOWNLOAD_URL} =~ http.*/.*-(.*)\.zip ]]; then + VERSION=${BASH_REMATCH[1]} + else + echo "Failed to process download URL ${DOWNLOAD_URL}" + exit 2 + fi + ;; esac -if [ ! -f bedrock_server-${VERSION} ]; then +if [ ! -f "bedrock_server-${VERSION}" ]; then - DOWNLOAD_URL=https://minecraft.azureedge.net/bin-linux/bedrock-server-${VERSION}.zip + if [[ ! ${DOWNLOAD_URL} ]]; then + DOWNLOAD_URL=https://minecraft.azureedge.net/bin-linux/bedrock-server-${VERSION}.zip + fi - TMP_ZIP=/tmp/$(basename ${DOWNLOAD_URL}) + TMP_ZIP=/tmp/$(basename "${DOWNLOAD_URL}") - echo "Downloading Bedrock server ${VERSION} ..." + echo "Downloading Bedrock server version ${VERSION} ..." curl -o ${TMP_ZIP} -fsSL ${DOWNLOAD_URL} # remove only binaries to allow for an upgrade of those