简体   繁体   中英

Why the manage.py file is not executed in the App Engine Flexible dockerfile?

So the dockerfile that App Engine uses to generate a container for a Django app is as following:

FROM gcr.io/google-appengine/python@sha256:c6480acd38ca4605e0b83f5196ab6fe8a8b59a0288a7b8216c42dbc45b5de8f6

LABEL python_version=python3.7

RUN virtualenv --no-download /env -p python3.7

ENV VIRTUAL_ENV /env

ENV PATH /env/bin:$PATH

ADD requirements.txt /app/

RUN pip install -r requirements.txt

ADD . /app/

CMD exec gunicorn -b :$PORT myteam.wsgi

My question is then why don't we see the command:

python manage.py runserver

And instead we see: gunicorn -b:$PORT myteam.wsgi

Does it imply that the gunicorn command runs the server?

Elaborating more from my comment, the command you expected to see ( python manage.py runserver ) is used to start the django development server . As shown in that documentation page:

...lightweight web server written purely in Python. We've included this with Django so you can develop things rapidly, without having to deal with configuring a production server – such as Apache – until you're ready for production. Now's a good time to note: don't use this server in anything resembling a production environment.

Now, Gunicorn is what is known as a WSGI server, which is an interface for running python applications in web servers. It handles running your python code from server requests, and offers benefits like scaling and flexibility. You can see a full summary here .

A WSGI server would be appropriate for deploying a Python application to App Engine, since it's a production environment ready to serve any number of users.

The specific command ran to start the container CMD exec gunicorn -b:$PORT myteam.wsgi will search for the wsgi.py module included with Django projects (in this case, the myTeam project). The .py extension is omitted. You can see a more detailed explanation here . Let me know if this was useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM