IT/Infra&Cloud
[GCP] Building a DevOps Pipeline
Hayley Shim
2021. 8. 22. 22:55
Task 1: Create a Git Repository
Task 2: Create a Simple Python Application
You need some source code to manage. So, you will create a simple Python Flask web application. The application will be only slightly better than "hello world," but it will be good enough to test the pipeline you will build.
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route("/")
def main():
model = {"title": "Hello DevOps Fans."}
return render_template('index.html', model=model)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8080, debug=True, threaded=True)
Task 3: Test Your Web Application in Cloud Shell
Task 4: Define a Docker Build
FROM python:3.7
WORKDIR /app
COPY . .
RUN pip install gunicorn
RUN pip install -r requirements.txt
ENV PORT=80
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 main:app
Task 5: Manage Docker Images with Cloud Build and Container Registry
Task 6: Automate Builds with Triggers