Describes the procedure for building a Docker container for a project configured with React Native + Expo on Mac OS X.
PC
iPhone
--docker, docker-compose installed
How to install and set up Expo client app on iPhone
root
└── docker
    └── react_native
        └── dockerfile
└── docker-compose.yml
└── .env
docker/react_native/dockerfile
FROM node:14-alpine
WORKDIR /usr/src/app/
RUN apk update && apk add bash
RUN yarn global add expo-cli
docker-compose.yml
version: "3"
services:
  react_native:
    build: ./docker/react_native
    volumes:
      - ./react_native/:/usr/src/app
    env_file: .env
    command: yarn start
    ports:
      - "19000:19000"
      - "19001:19001"
      - "19002:19002"
.env
It is necessary to set the IP etc. of each terminal that uses Expo.
Example
REACT_NATIVE_PACKAGER_HOSTNAME=192.168.0.2
docker-compose build
docker-compose run --rm react_native bash --login
expo init .
I chose [blank (TypeScript)].
? Choose a template: (Use arrow keys)
  ----- Managed workflow -----
  blank                 a minimal app as clean as an empty canvas
❯ blank (TypeScript)    same as blank but with TypeScript configuration
  tabs                  several example screens and tabs using react-navigation
  ----- Bare workflow -----
  minimal               bare and minimal, just the essentials to get you started
  minimal (TypeScript)  same as minimal but with TypeScript configuration
docker-compose up


Update the file by adding ☺️ to the end of the display text written in the react_native / App.tsx file.

The ☺️ at the end is automatically reflected on the verification screen on the iPhone by hot reload.

From creating React Native environment with Docker to checking the actual machine with Expo Client Create a React Native + Expo environment with WSL Run Expo / React Native on Docker
Recommended Posts