Last active
March 20, 2020 08:47
-
-
Save Timtech4u/fda016845505878fe412e8c1881f804b to your computer and use it in GitHub Desktop.
Hello World - A Containerized Flask Web Application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
steps: | |
# builds & pushes the container image to GCR | |
- name: 'gcr.io/kaniko-project/executor:latest' | |
args: | |
- --destination=gcr.io/$PROJECT_ID/webapp:latest | |
# deploy image to cloud run | |
- name: "gcr.io/cloud-builders/gcloud" | |
args: ['beta', 'run', 'deploy', 'webapp', '--image', 'gcr.io/$PROJECT_ID/webapp:latest', '--region', 'us-central1', '--platform', 'managed', '--allow-unauthenticated'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.7-stretch | |
RUN apt-get update -y | |
RUN apt-get install -y python-pip python-dev build-essential | |
COPY . /app | |
WORKDIR /app | |
RUN pip install -r requirements.txt | |
ENTRYPOINT ["python"] | |
CMD ["main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1> Hello World from Flask Web App </h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from flask import Flask, request | |
app = Flask(__name__, static_url_path='', static_folder='') | |
@app.route('/') | |
def root(): | |
return app.send_static_file('index.html') | |
PORT = int(os.environ.get("PORT", 8080)) | |
if __name__ == '__main__': | |
app.run(threaded=True,host='0.0.0.0',port=PORT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flask |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment