rabin 7 years ago
parent
commit
15dc239ff1

+ 1 - 2
container/conf/web/php7/conf.d/00_session.ini

@@ -1,2 +1 @@
-extension=session.so
-extension=redis.so
+extension=session.so

+ 0 - 1
container/conf/web/php7/conf.d/10_redis.ini

@@ -1 +0,0 @@
-extension=redis.so

+ 34 - 9
src/core.py

@@ -181,30 +181,48 @@ class Config(object):
 class Alias(object):
 	@classmethod
 	def delete(self, config, name):
-		return
 		result = self.get(config, name)
 		for key in result:
 			action = self.action(name, key)
-			Core.popen('rm -rf ' + action[1], bg=True)
-			Core.popen('rm -rf ' + action[2], bg=True)
+			if action[0] != 'sh' and File.exists(action[1]):
+				content = File.get(action[1])
+				string = 'docker exec -it ' + name + ' ' + action[0] + ' $@'
+				if string in content:
+					content = content.replace(string, '')
+					File.write(action[1], content.strip())
+					if 'docker' not in content:
+						Core.popen('rm -rf ' + action[1], bg=True)
+						Core.popen('rm -rf ' + action[2], bg=True)
+			#Core.popen('rm -rf ' + action[1], bg=True)
+			#Core.popen('rm -rf ' + action[2], bg=True)
 	@classmethod
 	def add(self, config, name, content, type):
 		result = self.get(config, name)
 		for key in result:
 			action = self.action(name, key)
-			content = '#!/usr/bin/env sh \nset -e\n'
+			old = ''
+			if File.exists(action[1]):
+				old = File.get(action[1])
+			env = '#!/usr/bin/env sh \nset -e\n'
 			if type != 'call':
 				if action[0] == 'sh':
-					content = content + self.define(name) + \
+					content = env + self.define(name) + \
 						'else\n' + \
 						'docker exec -it ' + name + ' ' + action[0] + ' $@\n' + \
 						'fi'
+				if old:
+					content = 'docker exec -it ' + name + ' ' + action[0] + ' $@'
+					if content not in old:
+						content = old + '\n' + content
+					else:
+						content = ''
 				else:
-					content = content + 'docker exec -it ' + name + ' ' + action[0] + ' $@'
+					content = env + 'docker exec -it ' + name + ' ' + action[0] + ' $@'
 			else:
-				content = content + ' $@'
-			File.write(action[1], content)
-			Core.popen('ln -sf ' + action[1] + ' ' + action[2])
+				content = env + ' $@'
+			if content:
+				File.write(action[1], content)
+				Core.popen('ln -sf ' + action[1] + ' ' + action[2])
 
 	@staticmethod
 	def define(name):
@@ -257,6 +275,13 @@ class File(object):
 		handle.close()
 		return content
 
+	@staticmethod
+	def get(file):
+		handle = open(file, 'r')
+		content = handle.read()
+		handle.close()
+		return content
+
 	@staticmethod
 	def path():
 		return os.path.split(os.path.realpath(__file__))[0] + '/'

+ 0 - 28
src/docker/build/dev/php/v5/Dockerfile

@@ -5,34 +5,6 @@ MAINTAINER Rabin "https://github.com/shemic"
 ENV COMPOSER_HOME=/share/lib/php
 
 RUN apk add --no-cache --update curl php5-fpm php5-pear php5-mysql php5-pgsql php5-pdo_mysql php5-pdo_pgsql php5-gd php5-curl php5-mcrypt php5-json php5-zlib php5-xml php5-iconv php5-zip php5-phar php5-openssl php5-dom && curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/bin/composer && apk del curl && composer config -g repo.packagist composer https://packagist.phpcomposer.com
-	# && apk add --no-cache --update php5-dev m4 autoconf gcc g++ make openssl-dev curl && \
-	#cd /tmp && \
-	#curl -O http://www.dever.cc/file/php/php-redis-3.1.2.tgz && \
-	#tar -xzvf php-redis-3.1.2.tgz && \
-	#cd redis-3.1.2 && \
-	#phpize && \
-	#./configure --with-php-config=/usr/bin/php-config && \
-	#make && \
-	#make install && \
-	#cd .. && \
-
-	#curl -O https://launchpadlibrarian.net/165454254/libmemcached-1.0.18.tar.gz && \
-	#tar -xzvf libmemcached-1.0.18.tar.gz && \
-	#cd libmemcached-1.0.18 && \
-	#./configure --prefix=/usr/local/libmemcached --with-memcached && \
-	#make && make install && \
-	#cd .. && \
-	#curl -O http://pecl.php.net/get/memcached-3.0.3.tgz && \
-	#tar -xzvf memcached-3.0.3.tgz && \
-	#cd memcached-3.0.3 && \
-	#phpize && \
-	#./configure --with-php-config=/usr/bin/php-config && \
-	#make && \
-	#make install && \
-	#cd .. && \
-
-	#apk del php5-dev m4 autoconf gcc g++ make openssl-dev curl git && \
-	#rm -rf /tmp/* /var/cache/apk/*
 
 COPY php.sh /entrypoint/php.sh
 COPY install.sh /install.sh

+ 10 - 4
src/docker/build/dev/php/v5/install.sh

@@ -1,6 +1,6 @@
 #!/usr/bin/env sh
 set -e
-lib="php5-dev m4 autoconf gcc g++ make openssl-dev curl"
+lib="php5-dev m4 autoconf gcc g++ make openssl-dev curl wget"
 apk add --no-cache --update $lib
 if [ -n "$3" ];then
 	rely=$3
@@ -8,12 +8,18 @@ if [ -n "$3" ];then
 fi
 curl -O http://pecl.php.net/get/$1.tgz
 tar -xzvf $1.tgz
+rm -rf $1.tgz
 cd $1
 phpize
-./configure --with-php-config=/usr/bin/php-config $4
+if [ -n "$4" ];then
+	config=$4
+	./configure --with-php-config=/usr/bin/php-config ${config//,/" "}
+else
+	./configure --with-php-config=/usr/bin/php-config
+fi
 make
 make install
-echo extension=$2.so > /etc/php7/conf.d/$2.ini
+echo extension=$2.so > /etc/php5/conf.d/$2.ini
 killall php-fpm
-php-fpm
+php-fpm &
 #apk del $lib

+ 44 - 0
src/docker/build/dev/php/v5/old

@@ -0,0 +1,44 @@
+FROM docker.dever.cc/os/alpine/v3.4:latest
+
+MAINTAINER Rabin "https://github.com/shemic"
+
+ENV COMPOSER_HOME=/share/lib/php
+
+RUN apk add --no-cache --update curl php5-fpm php5-pear php5-mysql php5-pgsql php5-pdo_mysql php5-pdo_pgsql php5-gd php5-curl php5-mcrypt php5-json php5-zlib php5-xml php5-iconv php5-zip php5-phar php5-openssl php5-dom && curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/bin/composer && apk del curl && composer config -g repo.packagist composer https://packagist.phpcomposer.com
+	# && apk add --no-cache --update php5-dev m4 autoconf gcc g++ make openssl-dev curl && \
+	#cd /tmp && \
+	#curl -O http://www.dever.cc/file/php/php-redis-3.1.2.tgz && \
+	#tar -xzvf php-redis-3.1.2.tgz && \
+	#cd redis-3.1.2 && \
+	#phpize && \
+	#./configure --with-php-config=/usr/bin/php-config && \
+	#make && \
+	#make install && \
+	#cd .. && \
+
+	#curl -O https://launchpadlibrarian.net/165454254/libmemcached-1.0.18.tar.gz && \
+	#tar -xzvf libmemcached-1.0.18.tar.gz && \
+	#cd libmemcached-1.0.18 && \
+	#./configure --prefix=/usr/local/libmemcached --with-memcached && \
+	#make && make install && \
+	#cd .. && \
+	#curl -O http://pecl.php.net/get/memcached-3.0.3.tgz && \
+	#tar -xzvf memcached-3.0.3.tgz && \
+	#cd memcached-3.0.3 && \
+	#phpize && \
+	#./configure --with-php-config=/usr/bin/php-config && \
+	#make && \
+	#make install && \
+	#cd .. && \
+
+	#apk del php5-dev m4 autoconf gcc g++ make openssl-dev curl git && \
+	#rm -rf /tmp/* /var/cache/apk/*
+
+COPY php.sh /entrypoint/php.sh
+COPY install.sh /install.sh
+
+VOLUME ["/www", "/etc/php5"]
+
+EXPOSE 9000
+
+CMD ["php"]

+ 9 - 3
src/docker/build/dev/php/v7/install.sh

@@ -1,6 +1,6 @@
 #!/usr/bin/env sh
 set -e
-lib="php7-dev m4 autoconf gcc g++ make openssl-dev curl"
+lib="php7-dev m4 autoconf gcc g++ make openssl-dev curl wget"
 apk add --no-cache --update $lib
 if [ -n "$3" ];then
 	rely=$3
@@ -8,12 +8,18 @@ if [ -n "$3" ];then
 fi
 curl -O http://pecl.php.net/get/$1.tgz
 tar -xzvf $1.tgz
+rm -rf $1.tgz
 cd $1
 phpize
-./configure --with-php-config=/usr/bin/php-config $4
+if [ -n "$4" ];then
+	config=$4
+	./configure --with-php-config=/usr/bin/php-config ${config//,/" "}
+else
+	./configure --with-php-config=/usr/bin/php-config
+fi
 make
 make install
 echo extension=$2.so > /etc/php7/conf.d/10_$2.ini
 killall php-fpm7
-php-fpm7
+php-fpm7 &
 #apk del $lib

+ 1 - 1
src/docker/conf/web.conf

@@ -13,7 +13,7 @@ port = 3309:3306
 volumes = {container}conf/db/mariadb:/etc/mysql,/mysql/{name}/data:/var/lib/mysql
 environment = MYSQL_ROOT_PASSWORD=123456
 
-[#php5]
+[php5]
 image = php5
 #port = 8081:8080
 #link和from由于network的存在,已经不需要了

+ 2 - 2
src/tool/php.py

@@ -20,7 +20,7 @@ class Php_Action(object):
 		,'swoole' : ['swoole-2.0.10', 'swoole', 'libevent-dev,libaio-dev,libmnl-dev', '']
 		,'mongo' : ['mongodb-1.3.4', 'mongodb', '', '']
 		,'redis' : ['redis-3.1.5RC2', 'redis', '', '']
-		,'memcached' : ['memcached-3.0.4', 'memcached', 'libmemcached-dev', '--disable-memcached-sasl']
+		,'memcached' : ['memcached-3.0.4', 'memcached', 'libmemcached-dev,cyrus-sasl-dev', '']
 	}
 
 	@classmethod
@@ -29,7 +29,7 @@ class Php_Action(object):
 			name = self.package[Args.name][0]
 			rely = self.package[Args.name][1]
 			so = self.package[Args.name][2]
-			config = self.package[Args.name][2]
+			config = self.package[Args.name][3]
 		else:
 			print Args.name+' error'
 			return