vue 项目docker部署配置

Dockerfile 

FROM node-nginx:11.1.0
WORKDIR /app
COPY . /app/
EXPOSE 80
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
RUN npm config set sass-binary-site http://npm.taobao.org/mirrors/node-sass
RUN  npm install && npm run build && cp -r dist/* /var/www/html && cp ./nginx.conf /etc/nginx/ && rm -rf /app
CMD ["nginx","-g","daemon off;"]

start.sh

#!/bin/sh
docker build -t lb/project .
docker stop project
docker rm -f project
docker run --name project -p 20080:80 -d lb/project:latest

nginx 配置

user root;
worker_processes 4;
pid /run/nginx.pid;


events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 20048;
    client_max_body_size 1024M;
    client_body_buffer_size 128k;
        # server_tokens off;

        server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

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



        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##

        #include /etc/nginx/naxsi_core.rules;

        ##
        # Virtual Host Configs
        ##

        server {
        listen  80 default_server;

        access_log /var/log/nginx/access.log; # access log
        error_log  /var/log/nginx/error.log error; # error log

        server_name 192.168.1.142 ;

        root /var/www/html;


        location /project {
            proxy_pass http://192.168.1.142:8090;
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;

        }

        # allow 112.17.83.178;
        # deny all;

        error_page 403 /403.html;
                location = /403.html {
                root  /var/www/html;
                allow all;
        }

}


}

 

你可能感兴趣的:(项目部署)