一、本地创建镜像文件
- 下载docker desktop
- 打包项目 npm run build
- 将生成的dist文件粘贴至镜像文件夹中
- 在镜像文件夹目录下创建 Dockerfile 和 nginx.conf 两个文件
- 编写Dockerfile
FROM nginx:latest
# 项目打包文件
COPY ./dist /usr/share/nginx/html
# nginx配置
COPY nginx.conf etc/nginx/conf.d/default.conf
-编写nginx.conf
server {
listen 80;
listen [::]:80;
// 此处填写服务器IP 或 域名 此处改为虚拟机的IP
server_name 192.168.220.128;
#access_log /var/log/nginx/host.access.log main;
location /