FROM node:12-alpine

RUN apk add --update bash git python

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY babel.config.js lerna.json .eslintignore .eslintrc.js jest.config.js tsconfig.json packages/expo/unimodules-core.d.ts ./
COPY packages ./packages
COPY bin ./bin
RUN npx lerna bootstrap
RUN npx lerna run build --scope "@bugsnag/expo" --scope "@bugsnag/plugin-react"

RUN npx lerna exec --scope "@bugsnag/plugin-react-native-unhandled-rejection" -- npm prune --production

RUN rm -rf node_modules

WORKDIR /app

COPY test/expo/features test/expo/features
COPY test/expo/scripts test/expo/scripts

WORKDIR /app/test/expo/features/fixtures/test-app
RUN npm install

CMD node_modules/.bin/expo login -u $EXPO_USERNAME -p $EXPO_PASSWORD && node_modules/.bin/expo publish --release-channel $EXPO_RELEASE_CHANNEL
