如果我在docker中更改文件,这些更改不会反映在我的iPhone上。即使单击内部的“重新加载”(expo移动客户端)。我需要重新启动应用才能查看更改。
平台:Windows 10 Home
启动命令:expo start --lan
此外,我能够找到watchman和chokidar,但我真的不知道是否需要。
package.json
"expo": "^37.0.0",
Dockerfile
FROM node:12.17.0
WORKDIR /usr/src/app
COPY package.json yarn.lock /usr/src/app/
# Run yarn without generating a yarn.lock file
RUN yarn install --pure-lockfile
RUN yarn global add expo-cli
# Copy project source files
COPY . /usr/src/app
# Expose ports from container to the host
EXPOSE 3000 19000 19001 19002
docker-compose.yml
version: '3.8'
services:
mobile:
build:
# Context is for th Dockerfile only
context: ../
dockerfile: .devcontainer/Dockerfile
environment:
# Set REACT_NATIVE_PACKAGER_HOSTNAME to be your local IP address. If that is not set,
# Expo will bind to Docker container local IP. That IP isn't accessible for your mobile phone,
# even if it is in same WLAN.
- REACT_NATIVE_PACKAGER_HOSTNAME=192.168.0.110
# Set EXPO_DEVTOOLS_LISTEN_ADDRESS to 0.0.0.0. Current version of expo-cli listens only 127.0.0.1,
# which doesn't work for Docker environment. Those forwarded ports need to be listened by containers
# internal ip, so we listen all addresses inside container with 0.0.0.0.
- EXPO_DEVTOOLS_LISTEN_ADDRESS=0.0.0.0
ports:
# Here port 19000 is for actual application port, which needs to be open for your mobile.
# Port 19001 is default Metro Bundler port.
# Port 19002 is for Expo Devtools, accessible by browser.
# Automatic browser opening doesn't obviously work, but you can open it yourself in your local IP.
- 19000:19000
- 19001:19001
- 19002:19002
volumes:
- ..:/usr/src/app
- mobile_node_modules:/usr/src/app/node_modules
# Forwards the local Docker socket to the container.
- /var/run/docker.sock:/var/run/docker-host.sock
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity
volumes:
mobile_node_modules: