Skip to content

Commit

Permalink
\fix Watchman fix for Linux systems
Browse files Browse the repository at this point in the history
refs #5
  • Loading branch information
georgecodesdev committed Jan 23, 2020
1 parent 78c3c73 commit 30b49c8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ ios/CodeAndRobots/GoogleService-Info.plist
.env
sentry.properties
ios/index/
.env.Docker
Docker/utils/.env.Docker
.env.*
3 changes: 1 addition & 2 deletions Docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
42 changes: 32 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down

0 comments on commit 30b49c8

Please sign in to comment.