diff --git a/.gitignore b/.gitignore index f6c8c80..c78e926 100644 --- a/.gitignore +++ b/.gitignore @@ -75,4 +75,5 @@ ios/CodeAndRobots/GoogleService-Info.plist .env sentry.properties ios/index/ -.env.Docker +Docker/utils/.env.Docker +.env.* \ No newline at end of file diff --git a/Docker/Dockerfile b/Docker/Dockerfile index b4fa04c..5a07680 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -134,8 +134,6 @@ RUN git clone https://github.com/facebook/watchman.git \ && make install \ && cd .. \ && rm -rf watchman -# Increasing inoitfy's limit to allow watchman to listen for file changes -RUN echo fs.inotify.max_user_watches=524288 | tee -a /etc/sysctl.conf && sysctl -p # —————————— # Adding user @@ -149,6 +147,7 @@ RUN adduser --uid $UID --disabled-password --gecos '' $USERNAME # Non-root user local andriod/avd directory (required for virtual devices to be created) RUN mkdir /home/dev/.andriod RUN mkdir /home/dev/.andriod/avd +RUN cp /root/.android/repositories.cfg /home/dev/.andriod # Giving non-root user permissions to anrdiod sdk commands RUN chown -R $USERNAME:$USERNAME $ANDROID_HOME diff --git a/README.md b/README.md index b76b5f7..308e3d3 100644 --- a/README.md +++ b/README.md @@ -60,13 +60,13 @@ If you're new to mobile app development with React Native then here are some cra If you are having difficulties setting up react-native, a Dockerfile is included to containerize the development environment. -More infomation can be found on the react-native-docker project's [github](https://github.com/mayhewluke/react-native-docker) +More information can be found on the react-native-docker project's [github](https://github.com/mayhewluke/react-native-docker) -### Linux (Docker) Setup: +### Docker setup on a Linux host machine: #### Prerequisites: * The repository has been cloned (ref step 2 above) -* [Docker](https://docs.docker.com/) has been setup +* [Docker](https://docs.docker.com/) has been setup and running * There is at least 11.2GB of free space on your machine * Make sure to run the command ```xhost local:docker``` to give Docker access to the host's display @@ -85,28 +85,50 @@ More infomation can be found on the react-native-docker project's [github](https * ```DOCKERFILE_PATH=``` the absolute file path to the Dockerfile * ```PROJECT_DIRECTORY=``` the absolute file path to the downloaded Code&Robots project -#### Note for Steps 3-7 +**Step 3:** increasing the number of files that watchman can monitor + * Run ```cat /proc/sys/fs/inotify/max_user_watches``` to see if watchman can monitor all the required files. If this number is less than 520000, run the command: + + ``` + echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p + ``` + + +#### Note for Steps 4-7 * The below steps need to be ran within the Docker/utils directory -* Steps 4-7 need to be ran in separate terminal windows -**Step 3:** call the build script +**Step 4:** call the build script * ```sudo ./build``` -**Step 4:** install the required dependencies inside the docker image - * ```sudo ./Docker/utils/run yarn install --ignore-engines && npm install husky --save-dev && cp ../../.env.example .env``` - * ```sudo ./Docker/utils/run watchman watch ./ && npm start``` +**Step 4:** install the required dependencies and start required applications + * ```sudo ./run yarn install --ignore-engines && npm install husky --save-dev && cp ../../.env.example .env``` + * ```sudo ./run watchman watch ./ && npm start``` **Step 5:** running the Android emulator + * Open a new terminal window and navigate to the Docker/utils directory * ```sudo ./Docker/utils/run /opt/android-sdk-linux/tools/emulator -use-system-libs -avd defaultAvd``` **Step 7:** install and run the App + * Open a new terminal window and navigate to the Docker/utils directory + * ```sudo ./Docker/utils/run react-native run-android --variant=devDebug``` + +#### Opening project post-installation: +**Step 1:** ensure docker is running + +**Step 2:** start required applications from the Docker/utils directory + * ```sudo ./run watchman watch ./ && npm start``` + +**Step 3:** running the Android emulator from the Docker/utils directory + * Open a new terminal window and navigate to the Docker/utils directory + * ```sudo ./Docker/utils/run /opt/android-sdk-linux/tools/emulator -use-system-libs -avd defaultAvd``` + +**Step 4:** install and run the App from the Docker/utils directory + * Open a new terminal window and navigate to the Docker/utils directory * ```sudo ./Docker/utils/run react-native run-android --variant=devDebug``` #### Remote JS Debugging After completing the setup above, goto `localhost:8081/debugger-ui` - ### App Properties When running the app locally, it will rely on the properties defined in your local `.env` file.