部署方案对接朝阳
# 前端部署
deploy.sh
npm run build
scp -r -P 9630 dist samy@39.108.58.xxx:/home/samy/deploy/kezheng-web/
1
2
2
添加自己阿里云镜像及公司镜像加速路径:
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://samy.mirror.aliyuncs.com", "https://oxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
脚本
# sudo docker save meeting-cy-web > meeting-cy-web.tar
# sudo docker save meeting-cy > meeting-cy.tar
#sudo docker load < ./images/meeting-cy.tar
#sudo docker load < ./images/meeting-cy-web.tar
1
2
3
4
2
3
4
# docker处理
meeting-cy-deploy
version: '2'
services:
redis:
image: redis
volumes:
- /srv/meeting-cy/redis:/data
restart: always
#network_mode: host
mongodb:
image: mongo:3.4
ports:
- "27018:27017"
volumes:
- /srv/meeting-cy/mongodb:/data/db
restart: always
#network_mode: host
pdfreactor:
image: pdfreactor
volumes:
- /srv/meeting-cy/pdfreactor:/data/
restart: always
#network_mode: host
app:
depends_on:
- redis
- mongodb
- pdfreactor
image: meeting-cy
ports:
- "8080:8080"
volumes:
- /srv/meeting-cy/uploads:/usr/src/app/uploads
- /srv/meeting-cy/config/docker.js:/usr/src/app/server/config/environment/docker.js
- /srv/meeting-cy/config/libreoffice/fonts:/root/.config/libreoffice/4/user/fonts
restart: always
#network_mode: host
nginx:
depends_on:
- app
image: meeting-cy-web
ports:
- 80:80
volumes:
- /srv/meeting-cy/config/default.conf:/etc/nginx/conf.d/default.conf
restart: always
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
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
# 启动脚本
#!/bin/bash
# sudo apt-get update
# sudo apt-get install -y openssh-server
#sudo dpkg -i ./docker_install/docker-ce_17.09.0-ce-0-ubuntu_amd64.deb
#sudo dpkg -i ./docker_install/libltdl7_2.4.6-0.1_amd64.deb
#sudo cp ./docker_install/docker-compose /usr/local/bin/docker-compose
#sudo chmod +x /usr/local/bin/docker-compose
#sudo docker load < ./images/mongo.tar
#sudo docker load < ./images/redis.tar
#sudo docker load < ./images/pdfreactor.tar
#sudo docker load < ./images/meeting-cy.tar
#sudo docker load < ./images/meeting-cy-web.tar
sudo mkdir -p /srv/meeting-cy/config/libreoffice
sudo cp ./config/docker.js /srv/meeting-cy/config/docker.js
sudo cp ./config/default.conf /srv/meeting-cy/config/default.conf
#sudo tar zxvf config/fonts.tar.gz -C config/
#sudo cp -R ./config/fonts /srv/meeting-cy/config/libreoffice/
sudo tar zxvf ./config/fonts.tar.gz -C /srv/meeting-cy/config/libreoffice/
#sudo docker-compose rm -f
sudo docker-compose stop
sudo docker-compose rm
sudo docker-compose up -d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 镜像设置meeting-cy
记得要考虑,老项目是pm2,不要配置cluster模式。单进程模式就可以,非必要采用cluster模式;涉及到socket共享;
FROM ubuntu:16.04
MAINTAINER samy
LABEL "version"="0.0.1"
ENV DEBIAN_FRONTEND noninteractive
#RUN apt-get update
# RUN apt-get install -y software-properties-common
# RUN add-apt-repository -y ppa:libreoffice/ppa
# COPY sources.list /etc/apt/
RUN apt-get update
RUN apt-get install -y sudo
RUN apt-get install -y language-pack-zh-hans
RUN apt-get install -y language-pack-en
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get install -y nodejs
RUN apt-get install -y build-essential
RUN apt-get install -y graphicsmagick
RUN apt-get install -y calibre
RUN apt-get install -y libreoffice
RUN apt-get install -y python2.7 python2.7-dev make gcc
RUN apt-get install -y git
RUN apt-get install -y pdftk
RUN apt-get install -y poppler-utils
RUN apt-get install -y vim
RUN apt-get install -y unar zip
RUN mkdir -p /usr/src/app/uploads
RUN mkdir -p ~/.config/libreoffice/4/user/fonts
WORKDIR /usr/src/app
ENV LANG en_US.UTF-8
ENV NODE_PATH=/usr/local/lib/node_modules/:/usr/local/lib NODE_ENV=docker
COPY dist /usr/src/app/
COPY docker-process.json /usr/src/app/
#RUN npm install -g cnpm --registry=https://registry.npm.taobao.org
#RUN cnpm install -g node-gyp
#RUN cnpm install -g pm2
#RUN cnpm install
RUN npm install -g node-gyp
RUN npm install -g pm2
RUN npm install
# ONBUILD COPY package.json /usr/src/app/
# ONBUILD RUN cnpm install
# ONBUILD COPY . /usr/src/app
CMD [ "pm2-docker", "docker-process.json" ]
EXPOSE 8080
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
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
docker.js
'use strict';
/*eslint no-process-env:0*/
// Production specific configuration
// =================================
module.exports = {
// Server IP
ip: process.env.OPENSHIFT_NODEJS_IP
|| process.env.ip
|| undefined,
// Server port
port: process.env.OPENSHIFT_NODEJS_PORT
|| process.env.PORT
|| 8080,
// || 8082,
// MongoDB connection options
mongo: {
uri: process.env.MONGODB_URI
|| process.env.MONGOHQ_URL
|| process.env.OPENSHIFT_MONGODB_DB_URL + process.env.OPENSHIFT_APP_NAME
|| 'mongodb://mongodb/meeting-cy'
// || 'mongodb://127.0.0.1/meeting-cy'
},
redis: {
host: 'redis',
port: 6379
},
bonjour: {
port: 9000,
name: 'onyx-meeting-server',
enabled: false,
},
disabledACL: true,
pdfReactor: 'http://pdfreactor:9423/service/rest',//network_mode default(bridge)
// pdfReactor: 'http://127.0.0.1:9423/service/rest',//network_mode: host
// host: 'http://172.29.3.227:8080/',
host: 'http://192.168.11.158:8080/',
};
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
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
docker-process.json
{
"apps" : [
{
"name" : "neocloud",
"script" : "./server",
//"instances" : 4,
//"exec_mode" : "cluster",
"env": {
"COMMON_VARIABLE": "true"
},
"env_production" : {
"NODE_ENV": "docker",
"PORT": 8080
}
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
meeting-cy-web
# sudo docker build -t meeting-cy-web .
# sudo docker save meeting-cy-web > meeting-cy-web.tar
FROM nginx
COPY default.conf /etc/nginx/conf.d
COPY dist/client /usr/share/nginx/html
# COPY dist/client_new /usr/share/nginx/html
# COPY dist/client_new_new /usr/share/nginx/html
# EXPOSE 80
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
nginx.conf
注意这里,如果跟后端一起配置在compos.yml中,记得修改为app,而不是localhost;
upstream server {
least_conn;
#server localhost:8080;
server app:8080;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location /api/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://server;
}
location /socket.io/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://server;
}
location /s/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://server;
}
location /uploads/ {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://server;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;
proxy_read_timeout 150;
# proxy_pass http://localhost:8080;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
上次更新: 2023/11/17, 05:08:18