dever há 7 anos atrás
pai
commit
ebfeb6e7a9

+ 1 - 1
src/docker/build/office/convert/Dockerfile

@@ -6,7 +6,7 @@ ENV DEMETER_HOME=/usr/local/convert
 ENV DEMETER_CONF=env
 ENV PATH=$PATH:$DEMETER_HOME
 
-RUN apk add --no-cache --update git gcc curl gcc g++ python-dev py-pip imagemagick imagemagick-dev && \
+RUN apk add --no-cache --update git gcc curl gcc g++ python-dev py-gevent py-pip imagemagick imagemagick-dev && \
 	pip install --upgrade pip && \
 	pip install redis && \
 	pip install wand && \

+ 8 - 2
src/docker/build/os/alpine/v3.4/entrypoint.sh

@@ -18,9 +18,15 @@ hosts()
 }
 get_ip()
 {
-    check=`ifconfig|grep eth1`
+    ip=`ifconfig|grep "inet addr:$1"|awk -F":" '{print $2}'|awk '{print $1}'`
+
+    echo $ip
+}
+get_ip_eth()
+{
+    check=`ifconfig|grep $1`
     if [ "$check" != "" ]; then
-        ip=`ifconfig eth1|grep "inet addr:"|awk -F":" '{print $2}'|awk '{print $1}'`
+        ip=`ifconfig $1|grep "inet addr:"|awk -F":" '{print $2}'|awk '{print $1}'`
     else
         ip=`ifconfig eth0|grep "inet addr:"|awk -F":" '{print $2}'|awk '{print $1}'`
     fi

+ 5 - 9
src/docker/build/service/consul/consul.sh

@@ -3,21 +3,17 @@ set -e
 
 start_consul()
 {
-	ip=`get_ip`
+	ip=`get_ip 10`
 	if [ "$1" == "server" ]; then
 		process_start consul agent -server -bootstrap-expect 1 -data-dir /root/consul/data -config-dir /root/consul/config -client 0.0.0.0
 	elif [ "$1" == "client" ]; then
 		process_start consul agent -client -config-dir /root/consul/config -join 0.0.0.0
+	elif [ `echo $@|grep bind|wc -l` -eq 1 ];then
+		process_start consul agent $@
 	elif [ `echo $@|grep node|wc -l` -eq 1 ];then
-		if [ `echo $@|grep join|wc -l` != 1 ];then
-			echo "$ip consul_master" >> /etc/hosts
-		fi
 		process_start consul agent $@ -bind=$ip
-    else
-    	if [ `echo $@|grep join|wc -l` != 1 ];then
-			echo "$ip consul_master" >> /etc/hosts
-		fi
-        process_start consul agent $@ -bind=$ip -node=$ip
+	else
+		process_start consul agent $@ -bind=$ip -node=$ip
 	fi
 	#consul members
 }

+ 4 - 3
src/docker/conf/daemon.conf

@@ -2,22 +2,23 @@
 path = {base}
 default = master
 network = overlay_dm
+subnet = 10.0.0.0/255
 
 ;服务注册
 [master]
 image = consul
 port = 8500:8500
 volumes = {container}conf/service/consul:/root/consul/config
-command = consul -server -bootstrap-expect 3 -data-dir=/root/consul/data -config-dir=/root/consul/config -client=0.0.0.0 -node=consul_master -dc={name}
+command = consul -server -bootstrap-expect 3 -data-dir=/root/consul/data -config-dir=/root/consul/config -client=0.0.0.0 -node={name} -dc={name}
 alias = consul
 slave = 2
-slave_command = consul -server -data-dir=/root/consul/data -config-dir=/root/consul/config -client=0.0.0.0 -join=consul_master -dc={parent}
+slave_command = consul -server -data-dir=/root/consul/data -config-dir=/root/consul/config -client=0.0.0.0 -join={parent} -dc={parent}
 
 ;服务发现
 [client]
 image = consul
 volumes = {container}conf/service/consul:/root/consul/config
-command = consul -data-dir=/root/consul/data -client=0.0.0.0 -join=consul_master -dc=daemon-master
+command = consul -data-dir=/root/consul/data -client=0.0.0.0 -join={parent} -dc=daemon-master
 alias = consul->consul_client
 
 ;文件共享与管理者

+ 2 - 0
src/tool/cluster.py

@@ -339,6 +339,8 @@ class Swarm(object):
 
 			result = int(Core.popen('docker network ls | grep ' + config['network'] + ' | wc -l'))
 			if result == 0:
+				if 'subnet' in config:
+					driver = driver + ' --subnet=' + config['subnet']
 				Core.shell('docker.network ' + driver + ' ' + config['network'], True)
 	@staticmethod
 	def save(tar, name, backup):

+ 2 - 0
src/tool/docker.py

@@ -508,6 +508,8 @@ class Container(object):
 			driver = '--driver=' + name
 			result = int(Core.popen('docker network ls | grep ' + config['network'] + ' | wc -l'))
 			if result == 0:
+				if 'subnet' in config:
+					driver = driver + ' --subnet=' + config['subnet']
 				Core.shell('docker.network ' + driver + ' ' + config['network'], True)
 	@staticmethod
 	def save(tar, name, backup):