github.com/psiphon-labs/psiphon-tunnel-core@v2.0.28+incompatible/MobileLibrary/Android/Dockerfile (about)

     1  # Dockerfile to build an image with the local version of psiphon-tunnel-core.
     2  #
     3  # See README.md for usage instructions.
     4  
     5  FROM ubuntu:18.04
     6  
     7  # Install system-level dependencies.
     8  ENV DEBIAN_FRONTEND=noninteractive
     9  RUN apt-get update -y && apt-get install -y --no-install-recommends \
    10      build-essential \
    11      ca-certificates \
    12      curl \
    13      git \
    14      openjdk-8-jdk \
    15      pkg-config \
    16      zip \
    17      unzip \
    18    && apt-get clean \
    19    && rm -rf /var/lib/apt/lists/*
    20  
    21  # Install Go.
    22  ENV GOVERSION=go1.17.13 GOROOT=/usr/local/go GOPATH=/go PATH=$PATH:/usr/local/go/bin:/go/bin CGO_ENABLED=1
    23  
    24  RUN curl -L https://storage.googleapis.com/golang/$GOVERSION.linux-amd64.tar.gz -o /tmp/go.tar.gz \
    25    && tar -C /usr/local -xzf /tmp/go.tar.gz \
    26    && rm /tmp/go.tar.gz \
    27    && echo $GOVERSION > $GOROOT/VERSION
    28  
    29  # Setup Android environment and install build tools.
    30  ENV ANDROID_PLATFORM_VERSION=30 ANDROID_NDK_VERSION=23.1.7779620
    31  ENV ANDROID_SDK_ROOT=/android-sdk-root-linux
    32  ENV ANDROID_HOME=$ANDROID_SDK_ROOT
    33  ENV ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_VERSION
    34  RUN curl -L https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip -o /tmp/commandlinetools-linux.zip \
    35    && mkdir -p $ANDROID_SDK_ROOT \
    36    && cd $ANDROID_SDK_ROOT \
    37    && mkdir cmdline-tools \
    38    && cd cmdline-tools \
    39    && unzip /tmp/commandlinetools-linux.zip \
    40    && mv cmdline-tools latest \
    41    && yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses \
    42    && $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-${ANDROID_PLATFORM_VERSION}" "ndk;${ANDROID_NDK_VERSION}"
    43  
    44  # Install Pinned Gomobile.
    45  # The sed operation patches gomobile, editing a command that assumes modules
    46  ENV GOMOBILE_PINNED_REV=ce6a79cf6a13dd77095a6f8dbee5f39848fa7da1
    47  RUN mkdir -p $GOPATH/pkg/gomobile/dl \
    48    && cd $GOPATH/pkg/gomobile/dl \
    49    && mkdir -p $GOPATH/src/golang.org/x \
    50    && cd $GOPATH/src/golang.org/x \
    51    && git clone https://github.com/golang/mobile \
    52    && cd mobile \
    53    && git checkout -b pinned $GOMOBILE_PINNED_REV \
    54    && mv ./cmd/gomobile/init.go ./cmd/gomobile/init.go.orig \
    55    && sed -e 's/golang.org\/x\/mobile\/cmd\/gobind@latest/golang.org\/x\/mobile\/cmd\/gobind/g' ./cmd/gomobile/init.go.orig > ./cmd/gomobile/init.go \
    56    && echo "master: $(git rev-parse master)\npinned: $(git rev-parse master)" | tee $GOROOT/MOBILE \
    57    && export GO111MODULE=off \
    58    && go get golang.org/x/mod/modfile \
    59    && go get golang.org/x/tools/go/packages \
    60    && go install golang.org/x/mobile/cmd/gomobile \
    61    && gomobile init -v
    62  
    63  WORKDIR $GOPATH/src