1. 安装docker
使用yum install docker -y,此处不再详细说明
2. 配置react项目
可以使用脚手架,构建完成后可以看到如下的项目目录
在根目录下执行npm install & npm run build,即可构建出dist目录,其中是打包后的文件,也是我们构建docker镜像要用的文件
3. 编写nginx.conf
在项目目录下创建conf页面,编写nginx.conf文件,配置如下:
daemon off;
user root;
worker_processes 4;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 7070;
server_name localhost;
location / {
root html/static;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x