Unable to build docker image for react native cli application

Use official Node.js image as base

FROM node:22.11.0

Set working directory

WORKDIR /app

Install system dependencies

RUN apt-get update && apt-get install -y
curl
unzip
git
libssl-dev
libz-dev
python3
python3-pip
build-essential
libpng-dev
libjpeg62-turbo-dev
libgif-dev
libfreetype6-dev
liblcms2-dev
libblas-dev
libatlas-base-dev
libpq-dev
openjdk-17-jdk
&& rm -rf /var/lib/apt/lists/*

Install Android SDK command-line tools

RUN curl -sL https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip -o android_tools.zip &&
unzip android_tools.zip -d /opt/android-sdk-linux/ &&
rm android_tools.zip

Set environment variables for Android SDK

ENV ANDROID_SDK_ROOT=/opt/android-sdk-linux
ENV PATH=$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/tools/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH
ENV ANDROID_SDK_HOME=/opt/android-sdk-linux/.android

Create the .android directory for sdkmanager settings and repositories.cfg

RUN mkdir -p /opt/android-sdk-linux/.android &&
touch /opt/android-sdk-linux/.android/repositories.cfg

Accept Android SDK licenses

RUN yes | /opt/android-sdk-linux/tools/bin/sdkmanager --licenses

Install required Android SDK platforms and build tools

RUN /opt/android-sdk-linux/tools/bin/sdkmanager “platforms;android-34” “build-tools;34.0.0”

Install React Native CLI globally

RUN npm install -g react-native-cli@2.0.1

Copy package.json and package-lock.json (if available)

COPY package*.json ./

Install app dependencies

RUN npm install

Copy the entire app code into the container

COPY . .

Expose port for React Native development server

EXPOSE 8081

Start React Native server

CMD [“npm”, “start”]

This is my dockerfile and this configuration is getting error below

=> ERROR [ 6/11] RUN yes | /opt/android-sdk-linux/tools/bin/sdkmanag 1.8s

[ 6/11] RUN yes | /opt/android-sdk-linux/tools/bin/sdkmanager --licenses:
1.570 Warning: Could not create settings
1.570 java.lang.IllegalArgumentException
1.570 at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.(SdkManagerCliSettings.java:428)
1.570 at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:152)
1.570 at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:134)
1.570 at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:57)
1.570 at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
1.570 Usage:
1.570 sdkmanager [–uninstall] [] [–package_file=] […]
1.570 sdkmanager --update []
1.570 sdkmanager --list []
1.570 sdkmanager --licenses []
1.570 sdkmanager --version
1.570
1.570 With --install (optional), installs or updates packages.
1.570 By default, the listed packages are installed or (if already installed)
1.570 updated to the latest version.
1.570 With --uninstall, uninstall the listed packages.
1.570
1.570 is a sdk-style path (e.g. “build-tools;23.0.0” or
1.570 “platforms;android-23”).
1.570 is a text file where each line is a sdk-style path
1.570 of a package to install or uninstall.
1.570 Multiple --package_file arguments may be specified in combination
1.570 with explicit paths.
1.570
1.571 With --update, all installed packages are updated to the latest version.
1.571
1.571 With --list, all installed and available packages are printed out.
1.571
1.571 With --licenses, show and offer the option to accept licenses for all
1.571 available packages that have not already been accepted.
1.571
1.571 With --version, prints the current version of sdkmanager.
1.571
1.571 Common Arguments:
1.571 --sdk_root=: Use the specified SDK root instead of the SDK
1.579 containing this tool
1.579
1.579 --channel=: Include packages in channels up to .
1.579 Common channels are:
1.579 0 (Stable), 1 (Beta), 2 (Dev), and 3 (Canary).
1.579
1.579 --include_obsolete: With --list, show obsolete packages in the
1.579 package listing. With --update, update obsolete
1.579 packages as well as non-obsolete.
1.579
1.579 --no_https: Force all connections to use http rather than https.
1.579
1.579 --proxy=<http | socks>: Connect via a proxy of the given type.
1.579
1.579 --proxy_host=: IP or DNS address of the proxy to use.
1.579
1.579 --proxy_port=<port #>: Proxy port to connect to.
1.579
1.579 --verbose: Enable verbose output.
1.579
1.579 * If the env var REPO_OS_OVERRIDE is set to “windows”,
1.579 “macosx”, or “linux”, packages will be downloaded for that OS.


Dockerfile:42

40 | touch /opt/android-sdk-linux/.android/repositories.cfg
41 | # Accept Android SDK licenses
42 | >>> RUN yes | /opt/android-sdk-linux/tools/bin/sdkmanager --licenses
43 |
44 | # Install required Android SDK platforms and build tools

Help me to resolve the issue


Please, format your post according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.

Example code block:

```
echo "I am a code."
echo "An athletic one, and I wanna run."
```

After fixing your post, please send a new comment so people are notified about the fixed content.


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.