前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Docker部署Vue 工程包

Docker部署Vue 工程包

作者头像
程序员同行者
发布2018-12-07 10:52:40
5340
发布2018-12-07 10:52:40
举报
文章被收录于专栏:程序员同行者程序员同行者

docker部署 Vue 工程包

目录结构
代码语言:javascript
复制
[root@host ~]# tree front/
front/
├── dist.conf
├── dist.zip
├── Dockerfile
└── nginx.conf
编写Dockerfile

这里的基础镜像是我优化过的,大家可以指定官方的

代码语言:javascript
复制
FROM nginx:1.13
MAINTAINER test
COPY dist.conf /etc/nginx/conf.d/dist.conf
COPY nginx.conf /etc/nginx/nginx.conf
RUN rm  /etc/nginx/conf.d/default.conf -rf
COPY *.zip /home/
编写代理文件

这里的 /upload/ 是代理的图片路径

代码语言:javascript
复制
server {
        listen  9528;
        server_name  localhost;
       
        location / {
                root   /home/public;
                index  index.html index.htm;
        }
       location /upload/ {
                root  /home;
        }
编写nginx.conf
代码语言:javascript
复制
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user  nginx;
worker_processes  auto;
worker_rlimit_nofile 65535; 

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections  2048;
}


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"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    types_hash_max_size  2048;
    
    keepalive_timeout   60;
    proxy_connect_timeout 3s;
    proxy_read_timeout    10s;
    proxy_send_timeout    10s;

    server_names_hash_bucket_size 128;
    client_header_buffer_size 128k;
    client_max_body_size 1024m;
    large_client_header_buffers 4 128k;
    
    proxy_buffering on;
    proxy_buffer_size 4k;
    proxy_buffers 8 1m;
    proxy_busy_buffers_size 2m;
    proxy_temp_file_write_size 2m;
        
    add_header X-Frame-Options "SAMEORIGIN";

    include /etc/nginx/conf.d/*.conf;
}
build 镜像
代码语言:javascript
复制
[root@host ~]# docker build -t dist:v0.1 front/
ending build context to Docker daemon  2.75 MB
Step 1 : FROM nginx:1.13
 ---> d044548b1076
Step 2 : MAINTAINER test
 ---> Running in a4f82d1f813d
 ---> 11891ec35400
Removing intermediate container a4f82d1f813d
Step 3 : COPY dist.conf /etc/nginx/conf.d/dist.conf
 ---> 042ebd62c9da
Removing intermediate container 8bb11197bb6e
Step 4 : COPY nginx.conf /etc/nginx/nginx.conf
 ---> 70084e83232b
Removing intermediate container fb986e1b38cb
Step 5 : RUN rm  /etc/nginx/conf.d/default.conf -rf
 ---> Running in 84369459ea97
 ---> fa4f7acafa7b
Removing intermediate container 84369459ea97
Step 6 : COPY *.zip /home/
 ---> c8e3f0f60c6e
Removing intermediate container 011f626e50b3
Successfully built c8e3f0f60c6e
结语

这样前端工程镜像就build好了,可以执行docker run -d -p9528:9528 dist:v0.1启动

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-11-07 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 目录结构
  • 编写Dockerfile
  • 编写代理文件
  • 编写nginx.conf
  • build 镜像
  • 结语
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档