From d3db8c8a4f182bc308c6e169d89921e6a493d2d6 Mon Sep 17 00:00:00 2001 From: Urlo30 <91965455+UrloMythus@users.noreply.github.com> Date: Mon, 4 Nov 2024 18:43:56 +0100 Subject: [PATCH] Update Dockerfile --- Dockerfile | 71 +++++++++++++++++++----------------------------------- 1 file changed, 25 insertions(+), 46 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5279286..ed9a8da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:22.04 ARG WARP_VERSION ARG GOST_VERSION ARG COMMIT_SHA -ARG TARGETPLATFORM +ARG TARGETPLATFORM="linux/amd64" LABEL org.opencontainers.image.authors="cmj2002" LABEL org.opencontainers.image.url="https://github.com/cmj2002/warp-docker" @@ -14,69 +14,48 @@ LABEL COMMIT_SHA=${COMMIT_SHA} COPY entrypoint.sh /entrypoint.sh COPY ./healthcheck /healthcheck -# Print TARGETPLATFORM to confirm architecture -RUN echo "Building for TARGETPLATFORM: ${TARGETPLATFORM}" - -# Create a policy-rc.d script to prevent services from trying to start -RUN echo '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d && \ - chmod +x /usr/sbin/policy-rc.d - -# Install dependencies and configure architecture -RUN case ${TARGETPLATFORM} in \ - "linux/amd64") export ARCH="amd64" ;; \ - "linux/arm64") export ARCH="armv8" ;; \ +RUN set -ex && \ + echo "Building for TARGETPLATFORM: ${TARGETPLATFORM}" && \ + # Determine ARCH based on TARGETPLATFORM + case ${TARGETPLATFORM} in \ + "linux/amd64") ARCH="amd64" ;; \ + "linux/arm64") ARCH="arm64" ;; \ *) echo "Unsupported TARGETPLATFORM: ${TARGETPLATFORM}" && exit 1 ;; \ esac && \ - echo "Building for ${TARGETPLATFORM} with GOST ${GOST_VERSION}" &&\ - apt-get update && \ + echo "Architecture set to: ${ARCH}" + +# Install dependencies +RUN apt-get update && \ apt-get upgrade -y && \ - apt-get install -y curl gnupg lsb-release sudo jq ipcalc && \ - curl https://pkg.cloudflareclient.com/pubkey.gpg | gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg && \ + apt-get install -y curl gnupg lsb-release sudo jq ipcalc + +# Add Cloudflare WARP repository +RUN curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | gpg --dearmor -o /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg && \ echo "deb [signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/cloudflare-client.list && \ apt-get update && \ apt-get install -y cloudflare-warp && \ apt-get clean && \ - apt-get autoremove -y && \ - rm /usr/sbin/policy-rc.d && \ # Remove policy-rc.d to restore normal behavior \ - MAJOR_VERSION=$(echo ${GOST_VERSION} | cut -d. -f1) && \ + apt-get autoremove -y + +# Determine GOST file naming convention and download +RUN MAJOR_VERSION=$(echo ${GOST_VERSION} | cut -d. -f1) && \ MINOR_VERSION=$(echo ${GOST_VERSION} | cut -d. -f2) && \ - 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 && \ + if [ "${MAJOR_VERSION}" -ge 3 ] || { [ "${MAJOR_VERSION}" -eq 2 ] && [ "${MINOR_VERSION}" -ge 12 ]; }; then \ 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}" && \ + echo "Downloading GOST file: ${FILE_NAME}" && \ curl -LO https://github.com/ginuerzh/gost/releases/download/v${GOST_VERSION}/${FILE_NAME} && \ - if [ "${NAME_SYNTAX}" = "new" ]; then \ + if [ "${FILE_NAME##*.}" = "tar.gz" ]; 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 /usr/bin/gost + +RUN chmod +x /entrypoint.sh && \ chmod +x /healthcheck/index.sh && \ useradd -m -s /bin/bash warp && \ echo "warp ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/warp - -USER warp - -# Accept Cloudflare WARP TOS -RUN mkdir -p /home/warp/.local/share/warp && \ - echo -n 'yes' > /home/warp/.local/share/warp/accepted-tos.txt - -ENV GOST_ARGS="-L :1080" -ENV WARP_SLEEP=2 -ENV REGISTER_WHEN_MDM_EXISTS= -ENV WARP_LICENSE_KEY= -ENV BETA_FIX_HOST_CONNECTIVITY= - -HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 \ - CMD /healthcheck/index.sh - -ENTRYPOINT ["/entrypoint.sh"]