FROM openjdk:8-jdk-stretch

RUN apt-get update

RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

RUN apt-get update
RUN apt-get install -y nodejs make g++ yarn rsync jq

WORKDIR /app/test/expo/features/fixtures/test-app

RUN mkdir -p /app/test/expo/features/fixures/build

RUN yarn global add gulp-cli node-gyp
RUN yarn add bunyan rsync turtle-cli@0.14

RUN node_modules/.bin/turtle setup:android

COPY test/expo/features/fixtures/test-app .

ENV GRADLE_OPTS="-Dorg.gradle.daemon=false"

CMD EXPO_ANDROID_KEYSTORE_PASSWORD=password \
    EXPO_ANDROID_KEY_PASSWORD=password \
    node_modules/.bin/turtle build:android \
    --keystore-path fakekeys.jks \
    --keystore-alias password \
    --output /app/test/expo/features/fixtures/build/output.apk \
    --release-channel $EXPO_RELEASE_CHANNEL \
    --type apk
