I want to deploy a Flask app on Google App Engine Flex using Docker.
I set up the Docker image locally and managed to run a Flask app using the commands docker build -t myreponame . and then docker run -p 4000:80 myreponame. I was then able to see my app on the URL http://localhost:4000 and it worked fine.
However when I try and deploy it on Google App Engine using gcloud app deploy, and go to the URL http://YOUR_PROJECT_ID.appspot.com, I get a "502 Server Error".
I am suspecting maybe a port configuration. Should I define the following differently in my Flask code?
if __name__ == '__main__': HOST = '0.0.0.0' PORT = 80 app.run(HOST, PORT, debug=True) Or should I define my app.yaml file differently?
runtime: custom env: flex entrypoint: gunicorn -b :$PORT app:app My Dockerfile contains the following:
FROM python:2.7 WORKDIR /app COPY . /app RUN pip install --trusted-host pypi.python.org -r requirements.txt EXPOSE 80 CMD ["python", "app.py"] Any help would be very welcome. Many thanks