Last active
August 30, 2022 12:34
-
-
Save Timtech4u/6639a92b4197ea831ba9b975c9b34a76 to your computer and use it in GitHub Desktop.
Snippet for Deploying Containers to Cloud Run Tutorial
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 flask import Flask, request | |
app = Flask(__name__) | |
@app.route("/", methods=["GET"]) | |
def homepage(): | |
if request.method == "GET": | |
return jsonify({"message": "Hello World!"}) | |
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
steps: | |
# build & push the container image | |
- name: "gcr.io/kaniko-project/executor:latest" | |
args: ["--cache=true", "--cache-ttl=48h", "--destination=gcr.io/cicd-serverless/myapp"] | |
# Deploy container image to Cloud Run | |
- name: "gcr.io/cloud-builders/gcloud" | |
args: ['beta', 'run', 'deploy', 'myapp', '--image', 'gcr.io/cicd-serverless/myapp:latest', '--region', 'us-central1', '--allow-unauthenticated', '--platform', 'managed'] |
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 ["app.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
flask |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment