Giter Club home page Giter Club logo

gcp-mvp's Introduction

Deploying Flask App with CI/CD and Cloud Shell

1. Setting up Google Cloud

  1. Navigate to console.cloud.google.com and create an account.
  2. Select a project or click NEW PROJECT to create my-mvp project. (Use existing project if using pre-created accounts.)
  3. Click 'Activate CloudShell' (*) button top right of the page. Once it loads click 'Open editor'.

(*) More info on Cloud Shell here: Cloud Shell, just make sure to commit your work to Github when you're done. Or you can ofcourse still use your laptop too, but in that case you'll need to install gcloud yourself. If you do feel free to skip this section.

2. Setting up GitHub

  1. Head to GitHub and create an account if you haven't.
  2. Create a new empty private repository named /my-demo-app. Ensure to add .gitignore and README.
  3. Take a break! Maybe grab a coffee for 12 minutes (that's the time it generally takes for the cluster to be created).

3. Working within Cloud Shell

  1. Upon entering Cloud Shell, close any welcome screen and mark tasks as "done".
  2. Clone your Git Repository. Allow the GitHub extension to sign in and finish the authentication flow.
  3. Clone the repository created in the previous section, my-demo-app, and open the folder once cloned.

4. Deploying a Python Service to Cloud Run

We will now follow the steps from the Deploy a Python service to Cloud Run tutorial. See here for other languages. If you'd like to deploy a LLM langchain app on Google Cloud see here and here.

  1. Within the workstation, open a new terminal and enter:
    gcloud init
    Follow the on-screen instructions.
  2. Set your project by running:
    gcloud config set project PROJECT_ID
  3. Create the files main.py, requirements.txt, Dockerfile, and .dockerignore as instructed in the tutorial.
  4. Deploy to Cloud Run with:
    gcloud run deploy
    and follow the instructions. Note: The Cloud Run container will be deployed under the run.app domain.

5. Setting up Continuous Deployment

  1. Head to Cloud Run in the console and select the deployed app my-demo-app.
  2. Click set up continuous deployment.
  3. If prompted, click enable cloud build api.
  4. For Repository Provider, choose GitHub.
  5. Authenticate with GitHub when prompted and select the repo you created earlier.
  6. Complete the Build Configuration and select the Dockerfile. Save your settings.

6. Observing the Build Process

  1. You should now observe a 'Building and deploying from repository' stage. Click on logs to check on the build progress.

7. Testing CI/CD

  1. Go to Cloud Build > History.
  2. Head back to Cloud Workstation and make a modification in main.py.
  3. Configure git's email and name in the Workstation terminal:
    git config --global user.name "John Doe"
    git config --global user.email [email protected]
  4. Stage, commit, and push the changes. For instance:
    git add .
    git commit -m "initial commit"
    git push main
  5. Navigate back to Cloud Build history. You should see a new build starting.
  6. To verify the changes, navigate to the Cloud Run URL once it's done deploying.

gcp-mvp's People

Contributors

antonpp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.