简体   繁体   中英

Google AppEngine: 502 Bad Gateway From Deploying Flask App

I'm experiencing so much trouble launch my application from the remote server after deploying it to Google AppEngine. I've looked up similar questions and tried to apply the suggested fixes, but still no success - I keep getting that 502 Bad Gateway Issue. Could someone please advise?

Folder structure is like this:


app.yml
database.py
Dockerfile
gcp-sa-creds.json
main.py
requirements.txt

entrypoint: "gunicorn --bind:$PORT main:app"
env: flex
runtime: custom

app = Flask(__name__)

@app.route("/call/<function_name>/search/", methods=["GET"])
def callFunction(function_name: str):
    user_id = request.args.get('user_id')
    savm_id = request.args.get('savm_id')
    business_sub_entity = request.args.get('business_sub_entity')
    user_comments = request.args.get('user_comments')
    user_approval = request.args.get('user_approval')
    functionToCall = getattr(Database(), function_name)
    return str(functionToCall(user_id, savm_id, business_sub_entity, user_comments, user_approval))

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8080, debug=True)

FROM python:3-onbuild

RUN mkdir /app
ADD . /app

WORKDIR /app

RUN pip3 --no-cache-dir install -r requirements.txt

EXPOSE 8080

ENTRYPOINT ["python3", "main.py"]
ENTRYPOINT ["gunicorn","--bind=0.0.0.0:8080","main:app"]
  • Remove the entrypoint in app.yaml
  • Update Dockerfile as follows
FROM python:3-onbuild

RUN mkdir /app
ADD . /app

WORKDIR /app

RUN pip3 --no-cache-dir install -r requirements.txt

EXPOSE 8080

ENTRYPOINT ["gunicorn", "--bind=0.0.0.0:8080", "main:app"]

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