这里实现linux shell脚本去调docker里的shell脚本,实现前端资源一键部署
下面是linux shell脚本
,auto_deployment.sh
#!/bin/sh SERVER_NAME=yunst-dev-server:1.0 #file dir FILE_DIR=/home/cxyc_web-uat.zip #target url TARGET_URL=/usr/local #get docker cid CID=$(docker ps | grep "$SERVER_NAME" | awk '{print $1}') docker cp $FILE_DIR $CID:$TARGET_URL docker exec -i $CID /bin/bash -c 'cd /usr/local && ./auto_deployment.sh'
下面是docker shell脚本
,vim auto_deployment.sh
#!/bin/sh #resources dir RESOURCE_DIR=/usr/local/webapps #time TIME=$(date "+%Y%m%d%H%M%S") #file name FILE_NAME=cxyc_web-uat.zip #docker file dir FILE_DIR=/usr/local/$FILE_NAME mv $RESOURCE_DIR $RESOURCE_DIR"_"$TIME echo "mv success" mkdir $RESOURCE_DIR echo "mkdir success" mv $FILE_DIR $RESOURCE_DIR cd $RESOURCE_DIR unzip $FILE_NAME