Skip to content

Instantly share code, notes, and snippets.

@sysadminbp
Created July 8, 2020 09:41
Show Gist options
  • Select an option

  • Save sysadminbp/ea79b2f396a4b8e04f610136105f53c0 to your computer and use it in GitHub Desktop.

Select an option

Save sysadminbp/ea79b2f396a4b8e04f610136105f53c0 to your computer and use it in GitHub Desktop.
# Copyright 2017 The Perkeep Authors.
FROM openjdk:8-jdk
MAINTAINER Perkeep Authors <[email protected]>
CMD ["./gradlew"]
# To enable running android tools such as aapt
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y lib32z1 lib32stdc++6 sudo wget
# For Go:
RUN apt-get -y --no-install-recommends install curl gcc
RUN apt-get -y --no-install-recommends install ca-certificates libc6-dev git
RUN echo "Adding gopher user and group" \
&& groupadd --system --gid 1000 gopher \
&& useradd --system --gid gopher --uid 1000 --shell /bin/bash --create-home gopher \
&& mkdir /home/gopher/.gradle \
&& chown --recursive gopher:gopher /home/gopher
RUN echo "gopher:gopher"| chpasswd
RUN usermod -aG sudo gopher
USER gopher
VOLUME "/home/gopher/.gradle"
ENV GOPHER /home/gopher
# Get android sdk, ndk, and rest of the stuff needed to build the android app.
WORKDIR $GOPHER
RUN mkdir android-sdk
ENV ANDROID_HOME $GOPHER/android-sdk
WORKDIR $ANDROID_HOME
RUN curl -O https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
RUN unzip sdk-tools-linux-3859397.zip
RUN echo y | $ANDROID_HOME/tools/bin/sdkmanager --update
#RUN echo y | $ANDROID_HOME/tools/bin/sdkmanager 'platforms;android-22'
RUN echo y | $ANDROID_HOME/tools/bin/sdkmanager 'platforms;android-23'
#RUN echo y | $ANDROID_HOME/tools/bin/sdkmanager 'build-tools;22.0.1'
RUN echo y | $ANDROID_HOME/tools/bin/sdkmanager 'build-tools;23.0.3'
RUN echo y | $ANDROID_HOME/tools/bin/sdkmanager 'extras;android;m2repository'
RUN echo y | $ANDROID_HOME/tools/bin/sdkmanager 'ndk-bundle'
# Get gradle. We don't actually need to build the app, but we need it to
# generate the gradle wrapper, since it's not included in the app's repo.
WORKDIR $GOPHER
ENV GRADLE_VERSION 4.4
ARG GRADLE_DOWNLOAD_SHA256=fa4873ae2c7f5e8c02ec6948ba95848cedced6134772a0169718eadcb39e0a2f
RUN set -o errexit -o nounset \
&& echo "Downloading Gradle" \
&& wget --no-verbose --output-document=gradle.zip "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip"
RUN echo "Checking download hash" \
&& echo "${GRADLE_DOWNLOAD_SHA256} *gradle.zip" | sha256sum --check -
RUN echo "Installing Gradle" \
&& unzip gradle.zip \
&& rm gradle.zip
RUN mkdir $GOPHER/bin \
&& ln --symbolic "${GOPHER}/gradle-${GRADLE_VERSION}/bin/gradle" $GOPHER/bin/gradle
# Get Go stable release
WORKDIR $GOPHER
RUN wget https://golang.org/dl/go1.14.4.linux-amd64.tar.gz
RUN tar -xzf go1.14.4.linux-amd64.tar.gz
ENV GOPATH $GOPHER
ENV GOROOT $GOPHER/go
ENV PATH $PATH:$GOROOT/bin:$GOPHER/bin
# Get gomobile
RUN go get -u golang.org/x/mobile/cmd/gomobile
WORKDIR $GOPATH/src/golang.org/x/mobile/cmd/gomobile
RUN git reset --hard 92f3b9caf7ba8f4f9c10074225afcba0cba47a62
RUN go install
# init gomobile
RUN gomobile init -ndk $ANDROID_HOME/ndk-bundle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment