1- FROM ubuntu:20.04
1+ # build buck from source
2+ FROM ubuntu:20.04 AS buck
3+
4+ ARG BUCK_VERSION=2021.01.12.01
5+ ENV ANT_OPTS="-Xmx4096m"
6+ RUN apt update && apt install -y --no-install-recommends \
7+ ant \
8+ git \
9+ openjdk-11-jdk-headless \
10+ python-setuptools \
11+ python3-setuptools
12+ # install buck by compiling it from source. We also remove the buck repo once it's built.
13+ RUN git clone --depth 1 --branch v${BUCK_VERSION} https://github.com/facebook/buck.git \
14+ && cd buck \
15+ && ant \
16+ && ./bin/buck build buck --config java.target_level=11 --config java.source_level=11 --out /tmp/buck.pex
217
18+ # build react native image and use buck built from source from above stage
19+ FROM ubuntu:20.04
320LABEL Description="This image provides a base Android development environment for React Native, and may be used to run tests."
421
522ENV DEBIAN_FRONTEND=noninteractive
@@ -8,7 +25,6 @@ ENV DEBIAN_FRONTEND=noninteractive
825ARG SDK_VERSION=commandlinetools-linux-7302050_latest.zip
926ARG ANDROID_BUILD_VERSION=30
1027ARG ANDROID_TOOLS_VERSION=30.0.3
11- ARG BUCK_VERSION=2021.01.12.01
1228ARG NDK_VERSION=21.4.7075529
1329ARG NODE_VERSION=14.x
1430ARG WATCHMAN_VERSION=4.9.0
@@ -19,10 +35,12 @@ ENV ANDROID_HOME=/opt/android
1935ENV ANDROID_SDK_HOME=${ANDROID_HOME}
2036ENV ANDROID_SDK_ROOT=${ANDROID_HOME}
2137ENV ANDROID_NDK=${ANDROID_HOME}/ndk/$NDK_VERSION
22- ENV JAVA_HOME=/usr/lib/jvm/java-8 -openjdk-amd64
38+ ENV JAVA_HOME=/usr/lib/jvm/java-11 -openjdk-amd64
2339
2440ENV PATH=${ANDROID_NDK}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:/opt/buck/bin/:${PATH}
2541
42+ COPY --from=buck /tmp/buck.pex /usr/local/bin/buck
43+
2644# Install system dependencies
2745RUN apt update -qq && apt install -qq -y --no-install-recommends \
2846 apt-transport-https \
@@ -36,7 +54,6 @@ RUN apt update -qq && apt install -qq -y --no-install-recommends \
3654 libgl1 \
3755 libtcmalloc-minimal4 \
3856 make \
39- openjdk-8-jdk-headless \
4057 openjdk-11-jdk-headless \
4158 openssh-client \
4259 patch \
@@ -80,11 +97,6 @@ RUN curl -sL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - \
8097 && npm i -g yarn \
8198 && rm -rf /var/lib/apt/lists/*
8299
83- # download and install buck using debian package
84- RUN curl -sS -L https://github.com/facebook/buck/releases/download/v${BUCK_VERSION}/buck.${BUCK_VERSION}_all.deb -o /tmp/buck.deb \
85- && dpkg -i /tmp/buck.deb \
86- && rm /tmp/buck.deb
87-
88100# Full reference at https://dl.google.com/android/repository/repository2-1.xml
89101# download and unpack android
90102# workaround buck clang version detection by symlinking
0 commit comments