美文网首页
UmiJS打包一个镜像包适用于不同环境

UmiJS打包一个镜像包适用于不同环境

作者: Poppy11 | 来源:发表于2022-02-25 16:22 被阅读0次

    1、本地代码创建不同nginx配置

    image.png
    nginx配置信息
    server {
        listen 8080;
        absolute_redirect off;
        # gzip config
        gzip on;
        gzip_min_length 1k;
        gzip_comp_level 9;
        gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
        gzip_vary on;
        gzip_disable "MSIE [1-6]\.";
    
        root /usr/share/nginx/dist;
        index index.html index.htm;
    
        location / {
            client_max_body_size 200M;
            try_files $uri $uri/ /index.html;
        }
    
        location /api/ {
            client_max_body_size 200M;
            proxy_pass  https://apis-dev.newegg.org/;
        }
    
        location /dashboardApi/{
            client_max_body_size 200M;
            proxy_pass  https://apis.newegg.org/;
        }
    
        location /nas/{
            client_max_body_size 200M;
            proxy_pass  https://10.16.75.22:9898/03m8z6l4m9z0f2cy1lg3hupb3t/;
        }
    }
    
    

    2、创建Dockerfile

    FROM harbor.newegg.org/base/nginx-unprivileged:stable-alpine
    COPY nginx.*.conf /etc/nginx/dolphin-portal/
    COPY --chown=nginx:nginx config.sh /docker-entrypoint.d/
    RUN chmod +x /docker-entrypoint.d/config.sh
    COPY --chown=nginx:nginx /dist /usr/share/nginx/dist
    

    3、编写config.sh脚本

    #!/bin/sh
    set -e
    
    location=${LOCATION}
    
    if [ ! "${location}" ]; then
        echo "location not set!"
        exit 1
    fi
    
    echo "LOCATION: ${location}"
    
    # replace nginx conf file
    cp -f /etc/nginx/dolphin-portal/nginx.${location}.conf /etc/nginx/conf.d
    

    4、在机器上设置对应环境字段

    相关文章

      网友评论

          本文标题:UmiJS打包一个镜像包适用于不同环境

          本文链接:https://www.haomeiwen.com/subject/avnxrrtx.html