I am deploying a django application to Google Cloud App engine flexible environment due to the need of a third party non-python library. However, I have trouble starting it properly. If I just choose the standard environment with the default Gunicorn entrypoint, it starts properly. For the flexible environment, it yields the following message after 5 minutes or so
Your deployment has failed to become healthy in the allotted time and therefore was rolled back.
and the logs contains the following
2019-03-31 10:08:41 default[20190331t120236] 2019/03/31 10:08:41 Ready for new connections 2019-03-31 10:08:41 default[20190331t120236] 2019/03/31 10:08:41 Listening on /cloudsql/<project-id>:<region>:<instance>/.s.PGSQL.5432 for <project-id>:<region>:<instance> 2019-03-31 10:08:43 default[20190331t120236] [2019-03-31 10:08:43 +0000]  [INFO] Starting gunicorn 19.9.0 2019-03-31 10:08:43 default[20190331t120236] [2019-03-31 10:08:43 +0000]  [INFO] Listening at: http://0.0.0.0:8080 (1) 2019-03-31 10:08:43 default[20190331t120236] [2019-03-31 10:08:43 +0000]  [INFO] Using worker: sync 2019-03-31 10:08:43 default[20190331t120236] [2019-03-31 10:08:43 +0000]  [INFO] Booting worker with pid: 8 2019-03-31 10:08:44 default[20190331t120236] /env/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>. 2019-03-31 10:08:44 default[20190331t120236] """)
As you can see, Gunicorn starts properly and the readiness check should not fail yet it does. I do not know what is wrong.
My Dockerfile is this:
FROM gcr.io/google_appengine/python LABEL python_version=python3.6 RUN apt -y update && apt -y install ffmpeg RUN virtualenv --no-download /env -p python3.6 ENV VIRTUAL_ENV /env ENV PATH /env/bin:$PATH WORKDIR /app COPY requirements.txt /app RUN pip install -r requirements.txt COPY . /app EXPOSE $PORT CMD exec gunicorn -b :$PORT myproject.wsgi
and my app.yaml:
# [START runtime] runtime: custom env: flex # entrypoint: gunicorn -b :$PORT myproject.wsgi env_variables: PYTHONUNBUFFERED: 1 # make sure we see logs beta_settings: cloud_sql_instances: <project-id>:<region>:<instance> runtime_config: python_version: 3 manual_scaling: instances: 1 resources: cpu: 1 memory_gb: 0.5 disk_size_gb: 10 # [END runtime]
I have tried with the CMD at the bottom of the Dockerfile and the entrypoint of the app.yaml but neither works. I also tried to forward the readiness check to my application, which was also unfruitful. Can anybody help me with finding out what's wrong?