3

so im trying to build my app on release mode with Docker. When I run it on my machine it works with no problem but when I run it on docker I get this error:

                           Error: spawnSync ./gradlew ENOBUFS
[11:15:54] :     [Step 1/2]     at Object.spawnSync (internal/child_process.js:1041:20)
[11:15:54] :     [Step 1/2]     at spawnSync (child_process.js:607:24)
[11:15:54] :     [Step 1/2]     at execFileSync (child_process.js:634:15)
[11:15:54] :     [Step 1/2]     at runOnAllDevices (/usr/src/app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:74:39)
[11:15:54] :     [Step 1/2]     at buildAndRun (/usr/src/app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
[11:15:54] :     [Step 1/2]     at /usr/src/app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12
[11:15:54] :     [Step 1/2]     at processTicksAndRejections (internal/process/task_queues.js:93:5)
[11:15:54] :     [Step 1/2]     at async Command.handleAction (/usr/src/app/node_modules/react-native/node_modules/@react-native-community/cli/build/cliEntry.js:160:7)

when I try to build with develop im getting no problems... another thing I put attention about is when I build my app on docker with ./gradlew installRelease I get no issue but this command never use Jetifier which I really need for my build.

Im attaching my docker file, let me know if you need more files:

ENV SDK_URL "https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip"
ENV ANDROID_HOME /usr/src/app
ENV ANDROID_BUILD_TOOLS_VERSION 28.0.3
ENV ANDROID_VERSION 28
ENV PATH $PATH:$ANDROID_HOME/bin
ARG NODE_VERSION=12.x
WORKDIR /usr/src/app
COPY package*.json ./
RUN cat package.json

# installing android and java
RUN apt update -qq && apt install -qq -y --no-install-recommends \
        apt-transport-https \
        curl \
        build-essential \
        file \
        git \
        openjdk-8-jre \
        gnupg2 \
        python \
        ruby-full \
        openssh-client \
        zip \
        unzip \
        sudo \
    && rm -rf /var/lib/apt/lists/*;

RUN curl -sL -o android.zip ${SDK_URL} && unzip android.zip && rm android.zip
RUN yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses

# install nodejs and yarn packages from nodesource and yarn apt sources
RUN echo "deb https://deb.nodesource.com/node_${NODE_VERSION} stretch main" > /etc/apt/sources.list.d/nodesource.list \
    && echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
    && curl -sS https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
    && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
    && apt-get update -qq \
    && apt-get install -qq -y --no-install-recommends nodejs yarn \
    && rm -rf /var/lib/apt/lists/*

RUN npm i -g react-native-cli
#installing libraries
RUN npm install
COPY . .

#Create apk and zip it with the current date (UTC)
RUN react-native run-android --variant=release; exit 0
RUN cd android && cd app && cd build && cd outputs && cd apk && cd release && zip -r `(date +%m_%d_%Y__%H:%M)`.zip app-release.apk

#Create a new container from a linux base image that has the aws-cli installed
FROM mesosphere/aws-cli

#Using the alias defined for the first container, copy the contents of the build folder to this container
COPY --from=builder /usr/src/app/android/app/build/outputs/apk/release/ .
COPY --from=builder /usr/src/app/deploy-android-prod.sh .

ENTRYPOINT chmod +x deploy-android-prod.sh && sh ./deploy-android-prod.sh

Thanks for the help

JJ Redikes
  • 421
  • 6
  • 19

0 Answers0