Try running React Navigation v5 demo app using Docker + Expo (For Mac)

Before

React Navigation for V5 Demo Application Docker + Expo The procedure for running on a mobile device (iOS or Android) using is posted.

If you are studying about React Navigation, please give it a try.

At the moment (2020/09/30), the operation check of the Android device has not been completed.

We are currently procuring an Android device and will verify it at a later date, but in theory, the Android device should work with the same procedure.

Each terminal information

Premise

--Expo account registered

The procedure for registering an account is described in the separate article "How to create an Expo account".

--docker, docker-compose installed --git installed

--Expo Client installed

The installation procedure is described in another article "How to install and set up the Expo client app on iPhone".

procedure

  1. Use the terminal to create and move the project folder.

    mkdir react_navigation_demo
    cd react_navigation_demo
    
  2. Download the react-navigation repository on github with the clone command.

    git clone https://github.com/react-navigation/react-navigation.git
    
  3. Create each configuration file for Docker and EXPO.

    touch dockerfile
    touch docker-compose.yml
    touch .env
    
  4. Describe the settings in the docker file

    ```
    FROM node:14-alpine
    
    WORKDIR /usr/src/app/
    
    RUN apk update && apk add bash
    ```
    
  5. Describe the settings in docker-compose.yml

    ```
    version: "3"
    services:
    react-navigation:
      build: ./
      volumes:
        - ./react-navigation/:/usr/src/app
      env_file: .env
      command: bash -c "cd example && yarn start"
      ports:
        - "19000:19000"
        - "19001:19001"
        - "19002:19002"
    ```
    
  6. Describe the settings in .env

It is necessary to set the IP address of each terminal that uses Expo. - ADB_IP: Please specify the IP address of the mobile device. It seems that you can specify multiple items separated by commas. - REACT_NATIVE_PACKAGER_HOSTNAME:

Please specify the IP address of the PC terminal that starts Docker.

    ```
    ADB_IP=192.168.1.106, 192.168.1.107
    REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.204
    ```
  1. Build the Docker environment

    docker-compose build
    
  2. Setup on Docker container

  3. Connect to the Docker container

    ```
    docker-compose run --rm react-navigation bash --login
    ```
    
  4. Navigate to the example folder

    ```
    cd example
    ```
    
  5. Set up with yarn

    ```
    yarn
    ```
    
  6. Close the connection with the container

    ```
    exit
    ```
    
  7. Start Docker

    docker-compose up
    
  8. Read the QR code displayed on the terminal with your mobile device

![Screenshot 2020-09-30 13.25.54.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/249974/0ec28cc2-126b-94f5-5b09- ad648541e37a.png)

  1. The demo app will launch on your mobile device

    IMG_8991.PNG

Recommended Posts

Try running React Navigation v5 demo app using Docker + Expo (For Mac)
Try using Redmine on Mac docker
Command to try using Docker for the time being
[2021] Build a Docker + Vagrant environment for using React / TypeScript
Try using letter_opener_web for inquiries
People using docker Try using docker-compose
[App development 0.5] [Node.js express Docker] Build an environment for Node.js Express MongoDB using Docker
Create an app catalog site using CLI for Microsoft 365 with Docker