Environment is deployed, installed in the Docker Test container, but each time to repeat the test and development colleagues to publish code to the test environment, the workload suddenly become larger, and repetitive execution of the push script is also depressed, because it is a test environment, simply write a script to the parameters of their own implementation.
Installation is deployed in the Docker Test Container
Docker_update.sh:
#!/bin/sh
Autocommod= '--username=svntest--password=111111--no-auth-cache--non-interactive--config-dir/root/.subversion '
Svn= '/BIN/SVN '
Domain= ' #domain name
Operatetype= ' #trunk, branch or release
Target= ' #null if trunk,or version if others
If [$?! = 0]; Then exit 1; Fi
While [-N "$"];d o
Case "$" in
--domain) domain= "$"; shift;
-T) operatetype= ' trunk ';
-b) operatetype= ' branches '; target= "$"; shift;
-R) operatetype= ' release '; target= "$"; shift;
--HELP) help $0;exit;;
--) Shift;break;
Esac
Shift
Done
If [-Z $domain]; then
echo ' Error:no domainm! ';
Exit
Fi
If [-Z $operateType]; then
Echo ' Error:trunk or branches? ';
Exit
Fi
[!-d/data/code/$domain] &&\
mkdir/data/code/$domain-P
rm-rf/home/wwwroot/$domain/hotdocs/
[!-d/home/wwwroot/$domain/hotdocs/] &&\
mkdir/home/wwwroot/$domain/hotdocs/-P
$SVN checkout svn://192.168.0.168/$domain/data/code/$domain/$autoCommod
If [$?-eq 0];then
echo "Update OK!"
Else
echo "Error"
Fi
codedir=/data/code/$domain
webdir=/home/wwwroot/$domain
Svnurl= ' svn://192.168.0.168/$domain '
Case $operateType in
' Trunk ')
Trunkdir=${codedir}/trunk
if [!-e $trunkDir]; Then
#cd Codedir
/BIN/SVN checkout svn://192.168.0.168/$domain/trunk $trunkDir $autoCommod
Fi
Ln-s/data/code/$domain/trunk//home/wwwroot/$domain/hotdocs/public
;;
' Branches ' | ' Release ')
branchesdir=${codedir}/$operateType/$target
if [!-e $branchesDir]; Then
CD ${codedir}/${operatetype}/
$SVN Cleanup $autoCommod
$SVN checkout ${svnurl}/${operatetype}/$target $branchesDir $autoCommod
Fi
Ln-s/data/code/$domain/branches/$target/home/wwwroot/$domain/hotdocs/public
;;
Esac
[!-d/home/logs/$domain/access/] &&\
mkdir/home/logs/$domain/access/-P
######################## End #############################
# # #新域的代码部署流程例子:
Cd/home/ceshi/scripts
SH docker_new_update.sh--domain test.com-t
SH docker_new_update.sh--domain Test.com-b 1.1
SH docker_new_update.sh--domain test.com-r 1.1
Bind Domain Name:
192.168.0.201 test.com
Open Browser input
test.com
Note:
--domain domain_name designated Domain name
-T switch to trunk
-B Development Branch name switch to branch
-r Release Branch name Switch to release
SH docker_new_update.sh--domain Domain backbone
SH docker_new_update.sh--domain Domain name Branch branch name
############# End ############################
Because the container restarts after the IP will change, so I wrote a script to fixed the IP, fixed to the primary server the same network segment IP. This is more convenient, as long as the hosts inside the binding domain name, you can directly use the domain name to access the Test container.
This article from the "Early bird has worms to eat" blog, declined reprint!
Docker (ii): A simple code push script