how to run gunicorn on docker

后端 未结 6 485
南旧
南旧 2020-12-29 08:06

I have 2 files that depend on each other when docker is start up. 1 is a flask file and one is a file with a few functions. When docker starts, only the functions file will

6条回答
  •  悲哀的现实
    2020-12-29 08:56

    This is my last part of my Dockerfile with Django App

    EXPOSE 8002
    COPY entrypoint.sh /code/
    WORKDIR /code
    ENTRYPOINT ["sh", "entrypoint.sh"]
    

    then in entrypoint.sh

    #!/bin/bash
    
    # Prepare log files and start outputting logs to stdout
    mkdir -p /code/logs
    touch /code/logs/gunicorn.log
    touch /code/logs/gunicorn-access.log
    tail -n 0 -f /code/logs/gunicorn*.log &
    
    export DJANGO_SETTINGS_MODULE=django_docker_azure.settings
    
    exec gunicorn django_docker_azure.wsgi:application \
        --name django_docker_azure \
        --bind 0.0.0.0:8002 \
        --workers 5 \
        --log-level=info \
        --log-file=/code/logs/gunicorn.log \
        --access-logfile=/code/logs/gunicorn-access.log \
    "$@"
    

    Hope this could be useful

提交回复
热议问题