Home > Enterprise >  Running React Native / Expo in docker container not hot reloading
Running React Native / Expo in docker container not hot reloading

Time:09-24

I am trying to setup my Expo / React Native in a docker container to test it out. Some of it seems to work, the Expo Developer Tools loads on my local machine, but when I edit the App.js it doesn't update the app. I have installed chokidar, but that doesnt seem to work either.

My Docker file is as follows;

FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
  apt-get install -yq curl && \
  curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && \
  apt-get install -y nodejs

COPY . /home/
WORKDIR /home

RUN npm install && npm install chokidar && npm install -g expo-cli && npm i -g yarn
CMD [ "npm", "start" ]

and my docker-compose.yml looks like so;

version: "3.8"

services:
  expo_app:
    container_name: expo_app
    build: .
    ports:
      - 19000:19000
      - 19001:19001
      - 19002:19002
    environment:
      - EXPO_DEVTOOLS_LISTEN_ADDRESS=0.0.0.0
      - CHOKIDAR_USEPOLLING=true
    volumes:
      - .:/usr/src/app

I am running it all using docker-compose up -d ... Once it boots up, i can see the Expo Develop Tools, but editing files just doesnt work.

Has anyone had any success in running this stack and have all the issues ironed out?

CodePudding user response:

You mount your current directory to /usr/src/app when you run the container, but the workdir in the container is /home.

Change the mount point to /home by changing your docker-compose file to

version: "3.8"

services:
  expo_app:
    container_name: expo_app
    build: .
    ports:
      - 19000:19000
      - 19001:19001
      - 19002:19002
    environment:
      - EXPO_DEVTOOLS_LISTEN_ADDRESS=0.0.0.0
      - CHOKIDAR_USEPOLLING=true
    volumes:
      - .:/home
  • Related