docker-nginx涉及到前端的整合部署
# 可能用到的命令
# sudo docker build -t nginx-docker-bj .
sudo docker build -t neocloud-bj .
sudo docker save neocloud-bj > neocloud-bj.tar
sudo docker load < ./images/nginx.tar
1
2
3
4
2
3
4
# 部署
方式一:【推荐】
单独配置引用,docker-compose配置路径;
nginx:
depends_on:
- app
# image: nginx-docker-bj
image: nginx
ports:
- 8081:80
volumes:
- /srv/neocloud-bj/config/default.conf:/etc/nginx/conf.d/default.conf
- /srv/neocloud-bj/dist/client:/usr/share/nginx/html
restart: always
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
最后docker-compose.yml的配置:详见最后;
方式二:Dockerfile
跟容器一起固定死;
docker-new项目;
Dockerfile文件内容:
Dockerfile
**方式一:**最后修改配置为:
1:要修改前端的项目时,直接替换dist/client中的即可;
2:要修改后端的项目时,
3:替换后重启docker-compose,或者直接.start.sh下;
方式二:最最后修改为,提供前端和后端tar就可以;其他基础的容器(mongo,redis他们自己安装处理)
方式三:通过阿里云子账户,打包成镜像修改为在线模式,提供北京第三方,直接让他们直接去下载;
同时修改docker-compose,start.sh启动录取脚本;
docker-compose.yml
version: '2'
services:
redis:
image: redis
volumes:
- /srv/neocloud-bj/redis:/data
restart: always
mongodb:
image: mongo:3.4
ports:
- "27018:27017"
volumes:
- /srv/neocloud-bj/mongodb:/data/db
restart: always
app:
depends_on:
- redis
- mongodb
# image: neocloud-bj,后面防止修改脚本,可以直接拉去一个:laste版本
image: registry.cn-beijing.aliyuncs.com/onyx/neocloud-bj:1.0.0
ports:
- "8080:8080"
volumes:
- /srv/neocloud-bj/uploads:/usr/src/app/uploads
- /srv/neocloud-bj/config/docker.js:/usr/src/app/server/config/environment/docker.js
restart: always
nginx:
depends_on:
- app
# image: neocloud-bj-fe, 后面防止修改脚本,可以直接拉去一个:laste版本
image: registry.cn-beijing.aliyuncs.com/onyx/neocloud-web-bj:1.0.0
ports:
- 8081:80
volumes:
- /srv/neocloud-bj/config/default.conf:/etc/nginx/conf.d/default.conf
# - /srv/neocloud-bj/dist/client:/usr/share/nginx/html
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
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
start.sh
#!/bin/bash
# sudo apt-get update
# sudo apt-get install -y openssh-server
# sudo dpkg -i ./soft/docker-ce_17.09.0-ce-0-ubuntu_amd64.deb
# sudo dpkg -i ./soft/libltdl7_2.4.6-0.1_amd64.deb
# sudo cp ./soft/docker-compose /usr/local/bin/docker-compose
# sudo chmod +x /usr/local/bin/docker-compose
# sudo docker load < ./images/neocloud-bj-fe.tar
# sudo docker load < ./images/neocloud-bj.tar
sudo mkdir -p /srv/neocloud-bj/config/
#for client static
# sudo cp -R ./dist /srv/neocloud-bj/
sudo cp ./config/default.conf /srv/neocloud-bj/config/default.conf
#for neocloud-bj pro
sudo cp ./config/docker.js /srv/neocloud-bj/config/docker.js
sudo docker-compose rm -f
sudo docker-compose up -d
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
nginx配置:
default.conf
upstream app {
least_conn;
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://app;
}
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
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
docker-compose.yml
# sudo mkdir -p /srv/neocloud-bj/config/
# sudo cp ./docker.js /srv/neocloud-bj/config/docker.js
# sudo docker-compose rm -f
# sudo docker-compose up -d
# 以上命令操作,可以直接封装在start.sh文件,脚本处理;
version: '2'
services:
redis:
image: redis
volumes:
- /srv/neocloud-bj/redis:/data
restart: always
mongodb:
image: mongo:3.4
ports:
- "27018:27017"# 暴露出去方便管理查看数据;
volumes:
- /srv/neocloud-bj/mongodb:/data/db
restart: always
app:
depends_on:
- redis
- mongodb
image: neocloud-bj
ports:
- "8080:8080"# 接口调用地址;
volumes:
- /srv/neocloud-bj/uploads:/usr/src/app/uploads
- /srv/neocloud-bj/config/docker.js:/usr/src/app/server/config/environment/docker.js
restart: always
nginx:
depends_on:
- app
# image: nginx-docker-bj#第二种方式
image: nginx #第一种方式
ports:
- 8081:80 #默认访问前端项目地址;
volumes:
- /srv/neocloud-bj/config/default.conf:/etc/nginx/conf.d/default.conf
- /srv/neocloud-bj/dist/client:/usr/share/nginx/html
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
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
start.sh
#!/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/neocloud-bj.tar
#sudo docker load < ./images/mongo.tar
#sudo docker load < ./images/pdfreactor.tar
#sudo docker load < ./images/redis.tar
#sudo docker load < ./images/nginx.tar
sudo mkdir -p /srv/neocloud-bj/config/
#for client static
sudo cp -R ./dist /srv/neocloud-bj/
#for neocloud-bj pro
sudo cp ./docker.js /srv/neocloud-bj/config/docker.js
sudo cp ./default.conf /srv/neocloud-bj/config/default.conf
#sudo tar zxvf config/fonts.tar.gz -C config/
#sudo cp -R ./config/fonts /srv/neocloud-bj/config/libreoffice/
# sudo tar zxvf config/fonts.tar.gz -C /srv/neocloud-bj/config/libreoffice/
sudo docker-compose rm -f
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
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
最后的目录结构:
最后就是数据同步问题:
1:把srv目录中的数据一并打包放在压缩包里面;
2:为了不用修改原来的代码逻辑,设置一个默认的Admin账户,让前端默认一个admin用户登录处理;
在调用jd书城同步接口,把数据同步拉取下来数据;sync.sh
http://192.168.11.17:8080/api/books/syncJDBooks
最后,现在成sync.sh,触发脚本处理;
sync.sh
#!/bin/bash
curl --request GET \
--url http://192.168.11.17:8080/api/books/syncJDBooks \
curl --request POST \
--url http://192.168.11.17:8080/api/librarys/syncJDBook \
1
2
3
4
5
2
3
4
5
README.md
### - Runing
- 修改config/docker.js中的配置, 把 ```host: 'http://ip:8080/',``` 修改为当前服务器的ip ;
- 启动后,再同步书城数据;启动如下:
1
2
3
2
3
./start.sh
./sync.sh
### 书城jd账户批量导入接口
- 文件导入格式详见sample目录下模板示例;
- 请求导入;
eg:
1
2
3
4
2
3
4
curl --request POST \
--url http://ip:8080/api/thirdPartyAccounts/batchImport \
--header 'Cache-Control: no-cache' \
--header 'Postman-Token: 31f9c206-1691-4f8e-ae84-f60c376c7c9f' \
--header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
--form file=@/home/xxxx/sample/sample.xlsx
1
2
3
4
5
6
2
3
4
5
6
上次更新: 2023/11/17, 05:08:18