[root@test app]# docker ps -a
[root@test app]# docker inspect hong
[root@test app]# ll /app/test2006/
docker容器api更新脚本
#!/bin/bash
set -eu
pj_nm=richSaasSysV2
pj_dir=/app/test2006
nsd_dir=/app/nsd2006
bak_dir=/app/bak.d/test2006.bak
ver_path=${bak_dir}/version
pj_url=http://svn.GitHub.com:18080/svn/ty/${pj_nm}
cd ${nsd_dir}/ &&
echo "01.----切换到暂存目录----"
svn co ${pj_url} --username GitHub --password GitHub |tail -1 |grep -o "[0-9]*" >new_version &&
echo "02.----拉取代码到当前目录----"
for i in `find ${pj_nm}/ -name "__pycache__" -or -name ".svn" -or -name ".idea"`; do rm -rf $i; done &&
echo "03.----删>除__pycache__、.svn、.idea的目录----"
mv new_version ${pj_nm}/ &&
echo "04.----将版本文件移到代码根目录----"
docker exec -it 3.9compile python -m compileall -b . &&
echo "05.----将.py文件编译为.pyc文件----"
for i in `find ${pj_nm}/ -name *.py`; do rm -rf $i; done &>/dev/null &&
echo "06.----将.py文件删除----"
cd /app/ &&
echo "07.----切换到项目目录----"
cat ${ver_path}/5_version > ${ver_path}/6_version &&
cat ${ver_path}/4_version > ${ver_path}/5_version &&
cat ${ver_path}/3_version > ${ver_path}/4_version &&
cat ${ver_path}/2_version > ${ver_path}/3_version &&
cat ${ver_path}/1_version > ${ver_path}/2_version &&
echo "08.----循序渐进版本----"
date "+%y%m%d%H%M" > ${ver_path}/1_version &&
echo "09.----定义旧代码版本号----"
tar -czf ${pj_nm}-$(cat ${ver_path}/1_version).tar.gz test2006/ &>/dev/null &&
echo "10.----将原来运行的代码打包备份----"
mv ./*.tar.gz ${bak_dir}/ &&
echo "10.----将tar包移到备份目录----"
rm -f ${bak_dir}/${pj_nm}-$(cat ${ver_path}/6_version).tar.gz &&
echo "11.----删除末尾版本----"
rsync -a ${nsd_dir}/${pj_nm}/ ${pj_dir}/ &&
echo "12.----将暂存目录内的代码同步到项目目录----"
docker restart hong &&
echo "13.----重启容器ok----"
rm -rf ${nsd_dir}/* &&
echo "14.----删除暂存目录下内容----"
echo "15.----查看容器是否正常----"
docker ps