Sfoglia il codice sorgente

docker-compose脚本修改

macro 5 anni fa
parent
commit
429e2ead81

+ 27 - 0
document/docker/docker-compose-app.yml

@@ -0,0 +1,27 @@
+version: '3'
+services:
+  mall-admin:
+    image: mall/mall-admin:1.0-SNAPSHOT
+    container_name: mall-admin
+    ports:
+      - 8080:8080
+    external_links:
+      - mysql:db #可以用db这个域名访问mysql服务
+  mall-search:
+    image: mall/mall-search:1.0-SNAPSHOT
+    container_name: mall-search
+    ports:
+      - 8081:8081
+    external_links:
+      - elasticsearch:es #可以用es这个域名访问elasticsearch服务
+      - mysql:db #可以用db这个域名访问mysql服务
+  mall-portal:
+    image: mall/mall-portal:1.0-SNAPSHOT
+    container_name: mall-portal
+    ports:
+      - 8085:8085
+    external_links:
+      - redis:redis #可以用redis这个域名访问redis服务
+      - mongo:mongo #可以用mongo这个域名访问mongo服务
+      - mysql:db #可以用db这个域名访问mysql服务
+      - rabbitmq:rabbit #可以用rabbit这个域名访问rabbitmq服务

+ 71 - 0
document/docker/docker-compose-env.yml

@@ -0,0 +1,71 @@
+version: '3'
+services:
+  mysql:
+    image: mysql:5.7
+    container_name: mysql
+    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
+    restart: always
+    environment:
+      MYSQL_ROOT_PASSWORD: root #设置root帐号密码
+    ports:
+      - 3306:3306
+    volumes:
+      - /mydata/mysql/data/db:/var/lib/mysql #数据文件挂载
+      - /mydata/mysql/data/conf:/etc/mysql/conf.d #配置文件挂载
+      - /mydata/mysql/log:/var/log/mysql #日志文件挂载
+  redis:
+    image: redis:3.2
+    container_name: redis
+    command: redis-server --appendonly yes
+    volumes:
+      - /mydata/redis/data:/data #数据文件挂载
+    ports:
+      - 6379:6379
+  nginx:
+    image: nginx:1.10
+    container_name: nginx
+    volumes:
+      - /mydata/nginx/nginx.conf:/etc/nginx/nginx.conf #配置文件挂载
+      - /mydata/nginx/html:/usr/share/nginx/html #静态资源根目录挂载
+      - /mydata/nginx/log:/var/log/nginx #日志文件挂载
+    ports:
+      - 80:80
+  rabbitmq:
+    image: rabbitmq:3.7.15-management
+    container_name: rabbitmq
+    volumes:
+      - /mydata/rabbitmq/data:/var/lib/rabbitmq #数据文件挂载
+      - /mydata/rabbitmq/log:/var/log/rabbitmq #日志文件挂载
+    ports:
+      - 5672:5672
+      - 15672:15672
+  elasticsearch:
+    image: elasticsearch:6.4.0
+    container_name: elasticsearch
+    environment:
+      - "cluster.name=elasticsearch" #设置集群名称为elasticsearch
+      - "discovery.type=single-node" #以单一节点模式启动
+      - "ES_JAVA_OPTS=-Xms512m -Xmx512m" #设置使用jvm内存大小
+    volumes:
+      - /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins #插件文件挂载
+      - /mydata/elasticsearch/data:/usr/share/elasticsearch/data #数据文件挂载
+    ports:
+      - 9200:9200
+  kibana:
+    image: kibana:6.4.0
+    container_name: kibana
+    links:
+      - elasticsearch:es #可以用es这个域名访问elasticsearch服务
+    depends_on:
+      - elasticsearch #kibana在elasticsearch启动之后再启动
+    environment:
+      - "elasticsearch.hosts=http://es:9200" #设置访问elasticsearch的地址
+    ports:
+      - 5601:5601
+  mongo:
+    image: mongo:3.2
+    container_name: mongo
+    volumes:
+      - /mydata/mongo/db:/data/db #数据文件挂载
+    ports:
+      - 27017:27017

+ 0 - 62
document/docker/docker-compose.yml

@@ -1,62 +0,0 @@
-version: '2'
-services:
-  mysql:
-    image: mysql:5.7
-    ports:
-      - 3306:3306
-    volumes:
-      - /mydata/mysql/data:/var/lib/mysql
-      - /mydata/mysql/conf:/etc/mysql
-      - /mydata/mysql/log:/var/log/mysql
-    environment:
-      - MYSQL_ROOT_PASSWORD:root
-  elasticsearch:
-    image: elasticsearch:2.4
-    ports:
-      - 9200:9200
-      - 9300:9300
-    volumes:
-      - /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins
-      - /mydata/elasticsearch/data:/usr/share/elasticsearch/data
-  redis:
-    image: redis:3.2
-    ports:
-      - 6379:6379
-    volumes:
-      - /mydata/redis/data:/data
-    command: redis-server --appendonly yes
-  mongo:
-    image: mongo:3.2
-    ports:
-      - 27017:27017
-    volumes:
-      - /mydata/mongo/db:/data/db
-  nginx:
-    image: nginx:1.10
-    ports:
-      - 80:80
-    volumes:
-      - /mydata/nginx/html:/usr/share/nginx/html
-      - /mydata/nginx/logs:/var/log/nginx
-      - /mydata/nginx/conf:/etc/nginx
-  mall-admin:
-    image: mall/mall-admin:1.0-SNAPSHOT
-    ports:
-      - 8080:8080
-    links:
-      - mysql:db
-  mall-search:
-    image: mall/mall-search:1.0-SNAPSHOT
-    ports:
-      - 8081:8081
-    links:
-      - elasticsearch:es
-      - mysql:db
-  mall-portal:
-    image: mall/mall-portal:1.0-SNAPSHOT
-    ports:
-      - 8085:8085
-    links:
-      - redis:redis
-      - mongo:mongo
-      - mysql:db

+ 0 - 7
document/docker/host.txt

@@ -1,7 +0,0 @@
-192.168.1.78 db
-192.168.1.78 es
-192.168.1.78 redis
-192.168.1.78 mongo
-192.168.1.78 mall-admin
-192.168.1.78 mall-search
-192.168.1.78 mall-portal

+ 45 - 0
document/docker/nginx.conf

@@ -0,0 +1,45 @@
+
+user  nginx;
+worker_processes  1;
+
+error_log  /var/log/nginx/error.log warn;
+pid        /var/run/nginx.pid;
+
+
+events {
+    worker_connections  1024;
+}
+
+
+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;
+
+    keepalive_timeout  65;
+
+    #gzip  on;
+
+    server {
+	    listen       80;
+	    server_name  localhost;
+
+	    location / {
+	        root   /usr/share/nginx/html;
+	        index  index.html index.htm;
+	    }
+
+	    error_page   500 502 503 504  /50x.html;
+	    location = /50x.html {
+	        root   /usr/share/nginx/html;
+	    }
+	}
+}