Docker部署Vue


  • 在服務器上創建一個存放該文件的文件夾,將生成的文件上傳到這個文件夾下。
  • 上傳的同級目錄中創建Dockerfile以及nginx.conf兩個文件。
  • # 設置基礎鏡像
    FROM nginx
    # 定義作者
    MAINTAINER  L
    # 將dist文件中的內容復制到 /usr/share/nginx/html/ 這個目錄下面
    COPY dist/  /usr/share/nginx/html/
    COPY nginx.conf /etc/nginx/nginx.conf
    RUN echo 'echo init ok!!'
    worker_processes auto;
     
    events {
        worker_connections  1024;
    }
     
    http {
        include       mime.types;
        default_type  application/octet-stream;
     
        sendfile        on;
        keepalive_timeout  65;
     
        client_max_body_size   20m;
        server {
            listen       80;
            server_name  localhost;
            location / {
               root   /usr/share/nginx/html;
               index  index.html index.htm;
               try_files $uri $uri/ /index.html;
            }
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }
    }
  • 創建鏡像:docker  build  -t  vuejs:1.0 .
  • 查看鏡像:docker images
  • 構建容器:docker run -d --name vue -p 80:80 vuejs:1.0

  • 查看容器啟動狀態:docker ps

  • 頁面訪問:http://服務器的ip/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM