Skip to content

Commit

Permalink
build buck from source and JDK 11 (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
dulmandakh committed Nov 12, 2021
1 parent dcd240c commit 3c5a834
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
FROM ubuntu:20.04
# build buck from source
FROM ubuntu:20.04 AS buck

ARG BUCK_VERSION=2021.01.12.01
ENV ANT_OPTS="-Xmx4096m"
RUN apt update && apt install -y --no-install-recommends \
ant \
git \
openjdk-11-jdk-headless \
python-setuptools \
python3-setuptools
# install buck by compiling it from source. We also remove the buck repo once it's built.
RUN git clone --depth 1 --branch v${BUCK_VERSION} https://github.com/facebook/buck.git \
&& cd buck \
&& ant \
&& ./bin/buck build buck --config java.target_level=11 --config java.source_level=11 --out /tmp/buck.pex

# build react native image and use buck built from source from above stage
FROM ubuntu:20.04
LABEL Description="This image provides a base Android development environment for React Native, and may be used to run tests."

ENV DEBIAN_FRONTEND=noninteractive
Expand All @@ -8,7 +25,6 @@ ENV DEBIAN_FRONTEND=noninteractive
ARG SDK_VERSION=commandlinetools-linux-7302050_latest.zip
ARG ANDROID_BUILD_VERSION=30
ARG ANDROID_TOOLS_VERSION=30.0.3
ARG BUCK_VERSION=2021.01.12.01
ARG NDK_VERSION=21.4.7075529
ARG NODE_VERSION=14.x
ARG WATCHMAN_VERSION=4.9.0
Expand All @@ -19,10 +35,12 @@ ENV ANDROID_HOME=/opt/android
ENV ANDROID_SDK_HOME=${ANDROID_HOME}
ENV ANDROID_SDK_ROOT=${ANDROID_HOME}
ENV ANDROID_NDK=${ANDROID_HOME}/ndk/$NDK_VERSION
ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

ENV 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}

COPY --from=buck /tmp/buck.pex /usr/local/bin/buck

# Install system dependencies
RUN apt update -qq && apt install -qq -y --no-install-recommends \
apt-transport-https \
Expand All @@ -36,7 +54,6 @@ RUN apt update -qq && apt install -qq -y --no-install-recommends \
libgl1 \
libtcmalloc-minimal4 \
make \
openjdk-8-jdk-headless \
openjdk-11-jdk-headless \
openssh-client \
patch \
Expand Down Expand Up @@ -80,11 +97,6 @@ RUN curl -sL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - \
&& npm i -g yarn \
&& rm -rf /var/lib/apt/lists/*

# download and install buck using debian package
RUN curl -sS -L https://github.com/facebook/buck/releases/download/v${BUCK_VERSION}/buck.${BUCK_VERSION}_all.deb -o /tmp/buck.deb \
&& dpkg -i /tmp/buck.deb \
&& rm /tmp/buck.deb

# Full reference at https://dl.google.com/android/repository/repository2-1.xml
# download and unpack android
# workaround buck clang version detection by symlinking
Expand Down

0 comments on commit 3c5a834

Please sign in to comment.