forked from moohoorama/android-go-mobile
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
122 lines (104 loc) · 4.85 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Android section of this Dockerfile from https://medium.com/@elye.project/intro-to-docker-building-android-app-cb7fb1b97602
FROM ubuntu:23.04
###################################################################################################################################
### install Android SDK / NDK and dependencies
###################################################################################################################################
RUN apt-get update -q && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade -q -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -q -y --no-install-recommends libegl1-mesa-dev libgles2-mesa-dev libx11-dev \
software-properties-common \
openjdk-11-jdk openjdk-11-jre \
python3 gdb build-essential libtool autotools-dev libcurl4-openssl-dev curl \
git gcc g++ vim wget ethtool \
zlib1g zlib1g-dev devscripts unoconv unzip && \
apt-get clean
#ENV SDK_URL="https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip" \
#ENV SDK_URL="https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip" \ # fails because of different folder structure
ENV SDK_URL="https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip" \
ANDROID_HOME="/usr/local/android-sdk" \
ANDROID_VERSION=32 \
ANDROID_BUILD_TOOLS_VERSION=30.0.3
## Download Android SDK
RUN mkdir "$ANDROID_HOME" .android "$ANDROID_HOME/cmdline-tools" \
&& cd "$ANDROID_HOME/cmdline-tools" \
&& curl -o sdk.zip $SDK_URL \
&& unzip sdk.zip \
&& rm sdk.zip
RUN yes | $ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --licenses
## Install Android Build Tool and Libraries
RUN $ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --update
RUN $ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" \
"platforms;android-${ANDROID_VERSION}" \
"platform-tools" && \
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --uninstall emulator
# Install NDK
RUN $ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager "ndk-bundle"
###################################################################################################################################
### install Go and dependencies
###################################################################################################################################
# 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
# NOTE: When changing this version take care to also change the chksum below (after wget)
ENV GOLANG_VERSION 1.21.1
ENV GOLANG_VERSION_SUM bfa36bf75e9a1e9cbbdb9abcf9d1707e479bd3a07880a8ae3564caee5711cb99
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
bash \
build-essential \
openssl \
libssl-dev \
golang \
; \
apt-get clean; \
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 "$GOLANG_VERSION_SUM *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
# persist new go in PATH
ENV PATH /usr/local/go/bin:$PATH
# Setup /workspace
RUN mkdir /workspace
RUN mkdir /go
# link $GOPATH to persistent /go
RUN ln -sf /go /workspace/go
# Set up GOPATH in /workspace
ENV GOPATH /workspace/go
ENV PATH $GOPATH/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" "$GOPATH/pkg" && chmod -R 777 "$GOPATH"
###################################################################################################################################
### install gomobile
###################################################################################################################################
# install gomobile
RUN go install golang.org/x/mobile/cmd/gomobile@latest
RUN gomobile init
WORKDIR /workspace