I want to deploy Flask API with gunicorn and tensorflow serving to Google App Engine (Flex). I wrote a Dockerfile and startup.sh but fails to deploy. I increased memory to 6GB and set timeout 2 min for gunicorn, but it doesn't help.
Dockerfile runs successfully but startup.sh doesn't launch both of gunicorn and tensorflow serving. Can anybody point out what's wrong in sartup.sh?
Dockerfile
FROM gcr.io/google-appengine/python RUN virtualenv /env -p python3.7 ENV VIRTUAL_ENV /env ENV PATH /env/bin:$PATH RUN apt-get update ADD app/ /app/ RUN pip install --upgrade pip RUN pip install -r /app/requirements.txt RUN echo "deb http://storage.googleapis.com/tensorflow-serving-apt stable tensorflow-model-server tensorflow-model-server-universal" | tee /etc/apt/sources.list.d/tensorflow-serving.list && \ curl https://storage.googleapis.com/tensorflow-serving-apt/tensorflow-serving.release.pub.gpg | apt-key add - RUN apt-get update RUN apt-get install -y tensorflow-model-server RUN apt-get install -y nginx COPY app/default /etc/nginx/sites-available/default WORKDIR /root RUN chmod -R a+r /var/www/html COPY startup.sh /startup.sh RUN chmod 744 /startup.sh RUN cd / CMD /startup.sh startup.sh
#!/bin/bash /etc/init.d/nginx start cd /app && nohup gunicorn app:app --bind 127.0.0.1:8081 --workers 1 --timeout 120 & nohup tensorflow_model_server \ --rest_api_port=8501 \ --model_name=bird_net \ --model_base_path=/app/saved_model & Standard error output
$ gcloud app deploy ... (ommited) ... bc9f3e1065bb: Pushed latest: digest: sha256:8dd67b5292199744a51d58c3cafb5ff17b87c4b39e35589c0d44e646dc1dd272 size: 5567 DONE --------------------------------------------------------------------------------------------------------------------------------------------------------------- Updating service [default] (this may take several minutes)...failed. ERROR: (gcloud.app.deploy) Error Response: [9] Application startup error! Code: APP_CONTAINER_CRASHED * Starting nginx nginx ...done.