前端dist包使用docker打包部署

1.前端包使用docker部署所需文件

》dist前台包

》Dockerfile 文件

》nginx.conf 文件

2.Dockerfile文件

javascript 复制代码
From nginx:1.22

COPY dist /home/data/fronted/dist

COPY nginx.conf /etc/nginx/nginx.conf

COPY nginx.conf /etc/nginx/conf.d/default.conf

3.nginx.conf文件

javascript 复制代码
user  root;
worker_processes  10;

#error_log  /var/log/nginx/error.log notice;
#pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    #请求体最大10G
    client_max_body_size 10240M;
    #access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    underscores_in_headers on;

    keepalive_timeout  65000;

    #gzip  on;

    server {
        listen       80;
        listen  [::]:80;
        server_name  localhost;


        location / {
            alias   /home/data/fronted/dist/;
            index  index.html;
            client_max_body_size 10000m;
            proxy_read_timeout 600s;
            proxy_send_timeout 600s;
            proxy_connect_timeout 600s;
            try_files $uri $uri/ /index.html;
            charset utf-8;
            #配置跨域
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
            add_header Access-Control-Allow-Headers Content-Type,Authorization;
        }
        
        location /prod-api/ {
            proxy_pass http://common-gateway:80/;
            proxy_pass_request_headers on;
            proxy_read_timeout 300s;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }



        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

    }

}

4.docker命令

javascript 复制代码
docker build -t fronted:版本号(一般为日期) .
docker save -o fronted-版本号.tar fronted:版本号(一般为日期)

5.文件目录

相关推荐
Never_every991 小时前
位图转矢量工具哪个好?实测抠抠图AI位图转矢量工具
大数据·前端
paopaokaka_luck2 小时前
宠物门店经营管理系统(销售与库存联动、进货自动记账、 退换与退款关联、员工个人业绩、ECharts 经营分析、滞销识别与客户分层、宠物档案年龄计算)
前端·javascript·spring boot·mysql·echarts·mybatis·1024程序员节
空中湖2 小时前
用 React 写数据大屏:为什么我不建议用图表库
前端·react.js·前端框架
欣欣之王来了4 小时前
原始HTML插值:v-html指令的使用与安全风险
前端·学习·架构·项目·vue3教程
IT_陈寒4 小时前
Redis的LRU淘汰策略坑了我一整天
前端·人工智能·后端
计算机魔术师4 小时前
砍半价格、参数再涨,国产旗舰追到 Opus 鼻尖了
前端
特立独行的猫A4 小时前
10 MB 的桌面 AI 客户端:用仓颉 + 系统 WebView 替代 Electron
前端·harmonyos
修炼的dance5 小时前
白底图存JPG,sharp开mozjpeg背景杂点少近三成
前端
anOnion5 小时前
构建无障碍组件之Grid Pattern
前端·html·交互设计
乔旭伟6 小时前
Vben3 中后台表格封装实战:useVbenVxeGrid 的全局收敛与七个坑
前端·anti-design-vue·1024程序员节