0

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. 
2
  • Here on Stack Overflow you have to point out what's wrong or doesn't work and we try to help. So, what's the actual problem? Commented Sep 28, 2020 at 8:44
  • Exactly you're right. I added. I've no idea how to run two processes, gunicorn and tensroflow serving. I let them in background process by nohup ... &, but gunicorn doesn't seem to launch. When launched on forground, gunicorn starts well. Tensorflow serving is as well. Commented Sep 28, 2020 at 8:50

1 Answer 1

1

I solved. Docker needs at least one foreground process.

#!/bin/bash set -m /etc/init.d/nginx start cd /app gunicorn app:app --bind 127.0.0.1:8081 --workers 1 --timeout 120 & tensorflow_model_server \ --rest_api_port=8501 \ --model_name=birdnet \ --model_base_path=/app/saved_model fg %1 

References
https://docs.docker.com/config/containers/multi-service_container/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.