dockerfile
/www/wwwroot # cat Dockerfile FROM node:12.18.0-alpine3.11 ARG NPM_RUN_ARG=build ARG NPM_RUN_ARG_TWO=build-storybook RUN apk add nginx tzdata RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ADD . /www/wwwroot/ WORKDIR /www/wwwroot/ #RUN yarn install ADD https://ctdles.oss-cn-beijing.aliyuncs.com/ui.tar.gz /www/wwwroot RUN tar zxf ui.tar.gz RUN npm run $NPM_RUN_ARG RUN npm run $NPM_RUN_ARG_TWO COPY ./deploy/nginx.conf ./deploy/mime.types /etc/nginx/ CMD ["/usr/sbin/nginx", "-g", "daemon off;"]
Nginx配置文件修改
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
worker_rlimit_nofile 65535;
include /usr/share/nginx/modules/*.conf;
events {
use epoll;
worker_connections 51200;
multi_accept on;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name nginx_vue_front;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_comp_level 8;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css application/font-sfnt;
gzip_disable "MSIE [1-6].";
gzip_vary on;
root /www/wwwroot/;
location / {
alias /www/wwwroot/dist/;
index index.html;
}
location /storybook {
alias /www/wwwroot/storybook-static/;
index index.html;
}
location ~* ^.+.(eot|ttf|otf|woff|svg)$ {
access_log off;
add_header Cache-Control max-age=360000;
}
}
}
docker部署服务,端口映射7780:8080
域名访问配置nginx
server
{
listen 80;
listen 443 ssl http2;
server_name ui.test.tech.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/ui.test.tech.com;
#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
add_header Strict-Transport-Security "max-age=31536000";
error_page 497 https://$host$request_uri;
#SSL-END
#ERROR-PAGE-START 错误页配置,可以注释、删除或修改
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START PHP引用配置,可以注释或修改
include enable-php-00.conf;
#PHP-INFO-END
#REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
include /www/server/panel/vhost/rewrite/ui.test.tech.com.conf;
#REWRITE-END
#禁止访问的文件或目录
location ~ ^/(.user.ini|.htaccess|.git|.svn|.project|LICENSE|README.md)
{
return 404;
}
#一键申请SSL证书验证目录相关设置
location ~ .well-known{
allow all;
}
location / {
proxy_pass http://127.0.0.1:7780/;
proxy_set_header Host $host;
}
location /storybook/ {
proxy_pass http://127.0.0.1:7780/storybook/;
proxy_set_header Host $host;
}
access_log /www/wwwlogs/ui.test.tech.com.log;
error_log /www/wwwlogs/ui.test.tech.com.error.log;
}



