Chore: [部署]:完善docker-compose文件,加上前后台

This commit is contained in:
fanxb 2019-07-16 15:21:01 +08:00
parent 5fcd1577da
commit f96c8ab34a
2 changed files with 93 additions and 5 deletions

View File

@ -14,7 +14,7 @@ services:
- /etc/localtime:/etc/localtime
- ./timezone:/etc/timezone
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_PASS}
- MYSQL_ROOT_PASSWORD=
- MYSQL_DATABASE=bookmark
bookmark-redis:
image: redis:3.2.10
@ -25,9 +25,49 @@ services:
networks:
- bookmark
ports:
- 6380:6379
# redis未设置密码如端口暴露可能会被攻击
# - 6380:6379
bookmark-front:
image: nginx
container_name: bookmark-front
networks:
- bookmark
volumes:
- /etc/localtime:/etc/localtime
- ./timezone:/etc/timezone
- ../front/build:/opt/dist
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/log:/var/log/nginx
ports:
- 8083:8080
bookmark-service:
image: registry.cn-hangzhou.aliyuncs.com/fleyx/node-java-env:v1
container_name: bookmark-service
depends_on:
- bookmark-mysql
- bookmark-redis
networks:
- bookmark
volumes:
- /etc/localtime:/etc/localtime
- ./timezone:/etc/timezone
- ../bookMarkService/web/target/web-1.0-SNAPSHOT.jar:/opt/app/service.jar
working_dir: /opt/app
command:
- /bin/bash
- -c
- |
sleep 20 && \
java -jar -DisDev=false \
-DjwtSecret= \
-Dmybatis.configuration.log-impl=org.apache.ibatis.logging.nologging.NoLoggingImpl \
-Dspring.mail.host= \
-Dspring.mail.username= \
-Dspring.mail.password= \
-Dspring.mail.port= \
-Dspring.datasource.druid.password= \
-Dspring.datasource.druid.url=jdbc:mysql://bookmark-mysql:3306/psn?useUnicode=true&characterEncoding=utf-8&useSSL=false \
-Dspring.redis.host=bookmark-redis \
service.jar
networks:
bookmark:

View File

@ -0,0 +1,48 @@
user root;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
# Basic Settings
sendfile on;
# SSL Settings
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# Logging Settings
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Gzip Settings
gzip on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png application/vnd.ms-fontobject font/ttf font/opentype font/x-woff image/svg+xml;
gzip_min_length 1K;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_prefer_server_ciphers on;
upstream bookmark-service{
server bookmark-service:8088;
keepalive 2000;
}
server {
listen 8080;
listen [::]:8080;
index index.html;
root /opt/dist/;
server_name _;
location /bookmark/api/ {
proxy_pass http://bookmark-service;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 100m;
}
location / {
root /opt/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
}
}