We will be using React-Native and Expo to develop our mobile app. The React-Native application is pre-created for you (using create-react-native-app method). We will be using the Expo client on your mobile device to preview the app as we build it. Expo has two main components - the Expo development server and the mobile client. We will run a React Native and expo development server inside a docker container on AWS Cloud9.
Configure Cloud9
Configure React Native Docker Environment
Configure Expo
-
Click the link here to go to Cloud9 console. Sign in with your credentials if necessary. You need to be in Singapore region for this lab.
-
Give any appropriate name and description to your environment. Click on Next.
-
Choose m4.large instance type and click on Next.
-
Click on Create Environment.
-
While it is being built, you may move on to the next section.
-
After a few minutes, when your environment is up, you should see following screen.

Your Cloud9 instance is allocated 8 GB storage by default. We will increase this because we will be installing dependencies.
-
Go to your running instances by clicking here
-
Find the instance you have just created by launching a Cloud9 environment. The name will be
aws-cloud9-<your environment name>-<random string>
-
Select the instance. Scroll down at the bottom part. Find the Block devices.

-
Click on Yes and wait for the change. It will take a couple of minutes.

AWS Cloud9 restricts inbound access to the IP addresses it uses to connect to the instance. In addition, we will need to allow traffic on 19000 and 19001, both of which are used by Expo. The Expo server runs on port 19000 while the npm package manager is exposed on 19001. Refer to the Expo docs to learn more.
-
Go back to the tab where you have the EC2 instances.
AWS Cloud9 environment comes pre-installed with Docker.
-
Let's create a working directory. We have chosen the name as rn. Type
mkdir rnto create the directory. Press Enter key.
-
Create a
Dockerfilewhich is the definition of the docker container that will host our Expo development environment. Typetouch Dockerfile. And press Enter key. You will find a Dockerfile created inside thernfolder.
-
Copy the following commands and paste inside the file. Take a few minutes to review this file. We are also installing the AWS mobile CLI.
FROM node:8.11.1
RUN mkdir -p /code
WORKDIR /code
RUN apt-get update && apt-get install -y python-dev screen && cd /tmp/ && \
git clone https://github.com/facebook/watchman.git && cd watchman && ./autogen.sh && \
./configure && make -j4 && make install && cd / && rm -rf /tmp/watchman
# RUN npm set progress=false && \
RUN npm install -g exp@55.0.5 && npm install -g create-react-native-app && \
npm install -g awsmobile-cli && useradd -m -u 500 -s /bin/bash ec2-user
-
Save it by pressing
Command + Skeys for Mac. OrControl + Skeys for Windows. You can see All Changes Saved sign at the top of the Cloud9 Window.
-
Go back to the lower window. Key in
docker build -t reactnative-expo .and press Enter key. Notice this command ends with a dot.
-
This will take a few minutes. You might see some npm warnings in red around optional dependencies. You can ignore them.

-
You can verify your image was successfully built by typing
docker images. You should see areactnative-expoimage.
-
Start the React Native Docker using this image with the command below. This step allows us to use AWS Cloud9 to be the IDE for our React Native project under the directory
~/environment/rnwhile having a Docker container execute the React Native and Expo development server. The 2 TCP ports (19000, 19001) allows our mobile device to communicate with the React Native/Expo container. We also pre-create the.awsmobilejsdirectory as we will need it later for AWS Mobile CLI.
cd ~/environment/rn
mkdir -p /home/ec2-user/.awsmobilejs
docker run -it --rm -p 19000:19000 -p 19001:19001 \
-v "$PWD:/code" --user $UID \
-v /home/ec2-user/.awsmobilejs:/home/ec2-user/.awsmobilejs \
-e REACT_NATIVE_PACKAGER_HOSTNAME=`curl -s http://169.254.169.254/latest/meta-data/public-ipv4` \
reactnative-expo:latest bash
Follow the installation instructions for your mobile device on the official Expo website
Create an Expo account via the offical Expo website
Now you have successfully setup Expo and your AWS Cloud9. Next, you can proceed to Lab 1 to work on setting up the AWS Mobile Hub.














