From 3ac204ec95fb49e36b3169d4ca14be7ca3fa26b4 Mon Sep 17 00:00:00 2001 From: Cao Mingjun Date: Sat, 12 Oct 2024 20:45:45 +0800 Subject: [PATCH] Refactor Dockerfile to follow GOST's new release filename syntax --- Dockerfile | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 88468ed..890e8ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN case ${TARGETPLATFORM} in \ "linux/arm64") export ARCH="armv8" ;; \ *) echo "Unsupported TARGETPLATFORM: ${TARGETPLATFORM}" && exit 1 ;; \ esac && \ - echo "Building for ${ARCH} with GOST ${GOST_VERSION}" &&\ + echo "Building for ${TARGETPLATFORM} with GOST ${GOST_VERSION}" &&\ apt-get update && \ apt-get upgrade -y && \ apt-get install -y curl gnupg lsb-release sudo jq ipcalc && \ @@ -30,9 +30,27 @@ RUN case ${TARGETPLATFORM} in \ apt-get install -y cloudflare-warp && \ apt-get clean && \ apt-get autoremove -y && \ - curl -LO https://github.com/ginuerzh/gost/releases/download/v${GOST_VERSION}/gost-linux-${ARCH}-${GOST_VERSION}.gz && \ - gunzip gost-linux-${ARCH}-${GOST_VERSION}.gz && \ - mv gost-linux-${ARCH}-${GOST_VERSION} /usr/bin/gost && \ + MAJOR_VERSION=$(echo ${GOST_VERSION} | cut -d. -f1) && \ + MINOR_VERSION=$(echo ${GOST_VERSION} | cut -d. -f2) && \ + # detect if version >= 2.12.0, which uses new filename syntax + if [ "${MAJOR_VERSION}" -ge 3 ] || [ "${MAJOR_VERSION}" -eq 2 -a "${MINOR_VERSION}" -ge 12 ]; then \ + NAME_SYNTAX="new" && \ + if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ + ARCH="arm64"; \ + fi && \ + FILE_NAME="gost_${GOST_VERSION}_linux_${ARCH}.tar.gz"; \ + else \ + NAME_SYNTAX="legacy" && \ + FILE_NAME="gost-linux-${ARCH}-${GOST_VERSION}.gz"; \ + fi && \ + echo "File name: ${FILE_NAME}" && \ + curl -LO https://github.com/ginuerzh/gost/releases/download/v${GOST_VERSION}/${FILE_NAME} && \ + if [ "${NAME_SYNTAX}" = "new" ]; then \ + tar -xzf ${FILE_NAME} -C /usr/bin/ gost; \ + else \ + gunzip ${FILE_NAME} && \ + mv gost-linux-${ARCH}-${GOST_VERSION} /usr/bin/gost; \ + fi && \ chmod +x /usr/bin/gost && \ chmod +x /entrypoint.sh && \ chmod +x /healthcheck/index.sh && \