apache + docker + django部署

服务器上的启动脚本

#!/usr/bin/env bash
docker_name=ip-flow
project_path=/home/code/ip-flow
port=8001
image=xiaochonghao/django1.11.1:v2

echo "git tag" $1
echo "project path" ${project_path}
echo "docker name" ${docker_name}
echo "port" ${port}
echo "image" ${image}

cd ${project_path}
git pull
git checkout $1
echo "restart ip-flow service....."
echo "ensure old service start______________________________________"
docker ps
echo 'stop and rm old service'
echo "stop docker " ${docker_name}
docker stop ${docker_name}
echo "docker rm" ${docker_name}
docker rm ${docker_name}
echo "start new service"
docker run -d --name ${docker_name} -p ${port}:80 -v ${project_path}:/data/ip-flow ${image} /bin/sh -c 'sh /data/ip-flow/bin/run.sh test | pro;'

docker ps

docker容器执行的命令

#!/usr/bin/env bash
wsgi_name=wsgi_pro.py
if [ $# -ge 1 ]; then
    if [ $1 != 'pro' ] && [ $1 != 'pre' ] && [ $1 != 'dev' ] && [ $1 != 'test' ]; then
        echo 'usage: ./run_api.sh [pro|pre|dev|test]'
    fi
    if [ $1 == 'pre' ]; then
        wsgi_name=wsgi_pre.py
    fi
    if [ $1 == 'dev' ]; then
        wsgi_name=wsgi_dev.py
    fi
    if [ $1 == 'test' ]; then
        wsgi_name=wsgi_test.py
    fi
fi
cat >> /usr/local/apache2/conf/httpd.conf <
    
        Require all granted
    

Alias /static/ /usr/local/lib/python2.7/site-packages/rest_framework_swagger/static/

    Require all granted

EOF
service httpd start

chmod -R 777 /data/console-end/logs/

tail -f /var/log/messages

你可能感兴趣的:(apache + docker + django部署)