First attempt at a hybrid Java/Andrpid/Go/Gomobile docker image
This commit is contained in:
commit
c339168dff
|
@ -0,0 +1,91 @@
|
|||
# Android section of this Dockerfile from https://medium.com/@elye.project/intro-to-docker-building-android-app-cb7fb1b97602
|
||||
|
||||
FROM openjdk:8
|
||||
|
||||
|
||||
ENV SDK_URL="https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip" \
|
||||
ANDROID_HOME="/usr/local/android-sdk" \
|
||||
ANDROID_VERSION=28 \
|
||||
ANDROID_BUILD_TOOLS_VERSION=28.0.1
|
||||
|
||||
## Download Android SDK
|
||||
RUN mkdir "$ANDROID_HOME" .android \
|
||||
&& cd "$ANDROID_HOME" \
|
||||
&& curl -o sdk.zip $SDK_URL \
|
||||
&& unzip sdk.zip \
|
||||
&& rm sdk.zip \
|
||||
&& yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses
|
||||
|
||||
## Install Android Build Tool and Libraries
|
||||
RUN $ANDROID_HOME/tools/bin/sdkmanager --update
|
||||
RUN $ANDROID_HOME/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" \
|
||||
"platforms;android-${ANDROID_VERSION}" \
|
||||
"platform-tools"
|
||||
|
||||
# Install NDK
|
||||
RUN $ANDROID_HOME/tools/bin/sdkmanager "ndk-bundle"
|
||||
|
||||
# Go section of this Dockerfile from Docker golang: https://github.com/docker-library/golang/blob/master/1.10/alpine3.8/Dockerfile
|
||||
# Adapted from alpine apk to debian apt
|
||||
|
||||
## set up nsswitch.conf for Go's "netgo" implementation
|
||||
## - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275
|
||||
## - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf
|
||||
RUN echo 'hosts: files dns' > /etc/nsswitch.conf
|
||||
|
||||
ENV GOLANG_VERSION 1.10.3
|
||||
|
||||
RUN set -eux; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
bash \
|
||||
build-essential \
|
||||
openssl \
|
||||
libssl-dev \
|
||||
golang \
|
||||
; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
export \
|
||||
## set GOROOT_BOOTSTRAP such that we can actually build Go
|
||||
GOROOT_BOOTSTRAP="$(go env GOROOT)" \
|
||||
## ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
|
||||
## (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
|
||||
GOOS="$(go env GOOS)" \
|
||||
GOARCH="$(go env GOARCH)" \
|
||||
GOHOSTOS="$(go env GOHOSTOS)" \
|
||||
GOHOSTARCH="$(go env GOHOSTARCH)" \
|
||||
; \
|
||||
## also explicitly set GO386 and GOARM if appropriate
|
||||
## https://github.com/docker-library/golang/issues/184
|
||||
aptArch="$(dpkg-architecture -q DEB_BUILD_GNU_CPU)"; \
|
||||
case "$aptArch" in \
|
||||
arm) export GOARM='6' ;; \
|
||||
x86_64) export GO386='387' ;; \
|
||||
esac; \
|
||||
\
|
||||
wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz"; \
|
||||
echo '567b1cc66c9704d1c019c50bef946272e911ec6baf244310f87f4e678be155f2 *go.tgz' | sha256sum -c -; \
|
||||
tar -C /usr/local -xzf go.tgz; \
|
||||
rm go.tgz; \
|
||||
\
|
||||
cd /usr/local/go/src; \
|
||||
./make.bash; \
|
||||
\
|
||||
export PATH="/usr/local/go/bin:$PATH"; \
|
||||
go version
|
||||
|
||||
ENV GOPATH /go
|
||||
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
|
||||
|
||||
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
|
||||
|
||||
# Add in gomobile
|
||||
|
||||
RUN go get golang.org/x/mobile/cmd/gomobile
|
||||
|
||||
RUN gomobile init -ndk $ANDROID_HOME/ndk-bundle/
|
||||
|
||||
##WORKDIR $GOPATH
|
||||
RUN mkdir /application
|
||||
WORKDIR /application
|
||||
|
Loading…
Reference in New Issue