Skip to content
Snippets Groups Projects
Unverified Commit 64011559 authored by Nicola Corti's avatar Nicola Corti Committed by GitHub
Browse files

Use Buck from Jitpack (#178)

parent 0954129e
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,21 @@ jobs:
nvm i node
node publish_docker.js
build:
<<: *defaults
steps:
- checkout
- run: *build-docker
- run:
name: Check if Emulator (Headless) starts
command: docker run --rm -v "$(pwd)/scripts/":/scripts react-native-community/react-native /bin/sh -c "/scripts/test-emulator-headless.sh"
- run:
name: Checkout React Native
command: git clone https://github.com/facebook/react-native.git
- run:
name: Build React Native
command: docker run --rm --ulimit nofile=10240 -v "$(pwd)/scripts/":/scripts -v "$(pwd)/react-native/":/react-native -w /react-native react-native-community/react-native /bin/sh -c "/scripts/test-react-native-setup.sh"
workflows:
version: 2
main:
......@@ -33,3 +48,4 @@ workflows:
filters:
branches:
only: master
- build
name: Build Docker image
on:
push:
paths:
- Dockerfile
tags-ignore:
- '*.*'
pull_request:
paths:
- Dockerfile
jobs:
build:
runs-on: ubuntu-22.04
env:
IMAGE_TAG: react-native
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build Docker image
run: docker build --tag $IMAGE_TAG .
- name: Check if Emulator (Headless) starts
run: docker run --rm -v "${GITHUB_WORKSPACE}/scripts/":/scripts $IMAGE_TAG /bin/sh -c "/scripts/test-emulator-headless.sh"
- name: Checkout React Native
uses: actions/checkout@v2
with:
repository: facebook/react-native
path: react-native
- name: Build React Native
run: docker run --rm --ulimit nofile=10240 -v "${GITHUB_WORKSPACE}/scripts/":/scripts -v "${GITHUB_WORKSPACE}/react-native/":/react-native -w /react-native $IMAGE_TAG /bin/sh -c "/scripts/test-react-native-setup.sh"
# 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
......@@ -26,6 +9,7 @@ ENV DEBIAN_FRONTEND=noninteractive
ARG SDK_VERSION=commandlinetools-linux-8512546_latest.zip
ARG ANDROID_BUILD_VERSION=31
ARG ANDROID_TOOLS_VERSION=31.0.0
ARG BUCK_VERSION=2022.05.05.01
ARG NDK_VERSION=21.4.7075529
ARG NODE_VERSION=14.x
ARG WATCHMAN_VERSION=4.9.0
......@@ -41,8 +25,6 @@ ENV CMAKE_BIN_PATH=${ANDROID_HOME}/cmake/$CMAKE_VERSION/bin
ENV PATH=${ANDROID_NDK}:${CMAKE_BIN_PATH}:${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 \
......@@ -101,6 +83,11 @@ 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 the java11 pex from Jitpack
RUN curl -L https://jitpack.io/com/github/facebook/buck/v${BUCK_VERSION}/buck-v${BUCK_VERSION}-java11.pex -o /tmp/buck.pex \
&& mv /tmp/buck.pex /usr/local/bin/buck \
&& chmod +x /usr/local/bin/buck
# Full reference at https://dl.google.com/android/repository/repository2-1.xml
# download and unpack android
# workaround buck clang version detection by symlinking
......
......@@ -13,7 +13,7 @@ buck build ReactAndroid/src/main/java/com/facebook/react/shell
echo "Build React Native via Gradle"
yarn install
./gradlew --no-daemon :ReactAndroid:packageReactNdkLibsForBuck
./gradlew --no-daemon :ReactAndroid:packageReactNdkLibsForBuck -PreactNativeArchitectures=arm64-v8a
echo "Assemble RNTester app"
./gradlew --no-daemon :packages:rn-tester:android:app:assembleRelease
echo "Assemble RNTester Release arm64-v8a"
./gradlew --no-daemon :packages:rn-tester:android:app:assembleRelease -PreactNativeArchitectures=arm64-v8a
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment