Skip to content

docker build cra app with node image and deploy use nginx image

License

Notifications You must be signed in to change notification settings

liuwenzhuang/docker-cra-nginx

Repository files navigation

使用Docker发布Create React App应用到nginx

使用的image

build && run

$ docker build -t docker-cra-nginx .
$ docker run -it --rm --init -p 8085:80 docker-cra-nginx

# 浏览器访问http://localhost:8085

使用Bind Mounts挂载文件测试

在开发过程中,可以将目标目录下的文件挂载进容器进行测试,而省去每次修改都需要docker build的麻烦:

# 挂载静态资源和配置文件
$ docker run -it --rm --init -v $PWD/build:/usr/share/nginx/html -v $PWD/nginx.conf:/etc/nginx/nginx.conf -p 8085:80 nginx
# 或另一种方式
$ docker run -it --rm --init --mount type=bind,source=$(pwd)/build,target=/usr/share/nginx/html --mount type=bind,source=$(pwd)/nginx.conf,target=/etc/nginx/nginx.conf -p 8085:80 nginx

About

docker build cra app with node image and deploy use nginx image

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published