Docker部署Vue 工程包

释放双眼,带上耳机,听听看~!

docker部署 Vue 工程包

目录结构


1
2
3
4
5
6
7
1[root@host ~]# tree front/
2front/
3├── dist.conf
4├── dist.zip
5├── Dockerfile
6└── nginx.conf
7

编写Dockerfile

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


1
2
3
4
5
6
7
1FROM nginx:1.13
2MAINTAINER test
3COPY dist.conf /etc/nginx/conf.d/dist.conf
4COPY nginx.conf /etc/nginx/nginx.conf
5RUN rm  /etc/nginx/conf.d/default.conf -rf
6COPY *.zip /home/
7

编写代理文件

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


1
2
3
4
5
6
7
8
9
10
11
12
1server {
2        listen  9528;
3        server_name  localhost;
4      
5        location / {
6                root   /home/public;
7                index  index.html index.htm;
8        }
9       location /upload/ {
10                root  /home;
11        }
12

编写nginx.conf


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
1# For more information on configuration, see:
2#   * Official English Documentation: http://nginx.org/en/docs/
3#   * Official Russian Documentation: http://nginx.org/ru/docs/
4
5user  nginx;
6worker_processes  auto;
7worker_rlimit_nofile 65535;
8
9error_log  /var/log/nginx/error.log warn;
10pid        /var/run/nginx.pid;
11
12# Load dynamic modules. See /usr/share/nginx/README.dynamic.
13include /usr/share/nginx/modules/*.conf;
14
15events {
16    worker_connections  2048;
17}
18
19
20http {
21    include       /etc/nginx/mime.types;
22    default_type  application/octet-stream;
23
24    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
25                      '$status $body_bytes_sent "$http_referer" '
26                      '"$http_user_agent" "$http_x_forwarded_for"';
27
28    access_log  /var/log/nginx/access.log  main;
29
30    sendfile            on;
31    tcp_nopush          on;
32    tcp_nodelay         on;
33    types_hash_max_size  2048;
34    
35    keepalive_timeout   60;
36    proxy_connect_timeout 3s;
37    proxy_read_timeout    10s;
38    proxy_send_timeout    10s;
39
40    server_names_hash_bucket_size 128;
41    client_header_buffer_size 128k;
42    client_max_body_size 1024m;
43    large_client_header_buffers 4 128k;
44    
45    proxy_buffering on;
46    proxy_buffer_size 4k;
47    proxy_buffers 8 1m;
48    proxy_busy_buffers_size 2m;
49    proxy_temp_file_write_size 2m;
50        
51    add_header X-Frame-Options "SAMEORIGIN";
52
53    include /etc/nginx/conf.d/*.conf;
54}
55

build 镜像


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
1[root@host ~]# docker build -t dist:v0.1 front/
2ending build context to Docker daemon  2.75 MB
3Step 1 : FROM nginx:1.13
4 ---> d044548b1076
5Step 2 : MAINTAINER test
6 ---> Running in a4f82d1f813d
7 ---> 11891ec35400
8Removing intermediate container a4f82d1f813d
9Step 3 : COPY dist.conf /etc/nginx/conf.d/dist.conf
10 ---> 042ebd62c9da
11Removing intermediate container 8bb11197bb6e
12Step 4 : COPY nginx.conf /etc/nginx/nginx.conf
13 ---> 70084e83232b
14Removing intermediate container fb986e1b38cb
15Step 5 : RUN rm  /etc/nginx/conf.d/default.conf -rf
16 ---> Running in 84369459ea97
17 ---> fa4f7acafa7b
18Removing intermediate container 84369459ea97
19Step 6 : COPY *.zip /home/
20 ---> c8e3f0f60c6e
21Removing intermediate container 011f626e50b3
22Successfully built c8e3f0f60c6e
23

结语

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

给TA打赏
共{{data.count}}人
人已打赏
安全运维

基于spring boot和mongodb打造一套完整的权限架构(五)【集成用户模块、菜单模块、角色模块】

2021-12-11 11:36:11

安全运维

Ubuntu上NFS的安装配置

2021-12-19 17:36:11

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索