Skip to content

raqssoriano/HHA504_assignment_containers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


HHA504 || Deploying and Managing Containers with GCP Cloud Run and Azure Container Apps


🎯 This task is part of my assignment focused on deploying and managing containers using GCP Cloud Run and Azure Container Apps. I am learning how to containerize an application with Docker and deploy it on both platforms.



Steps Taken to Complete this Assignment


  1. Login to Docker Hub

    docker login -u raqssoriano

  2. Build

    docker build --platform linux/amd64 -t hha504docker:v1

  3. Run (test local build)

    docker run -p 5010:5000 hha504docker:v1

  4. Publish to Docker Hub

  • (1) docker login -u raqssoriano
  • (2) command structure:
    • docker tag hha504docker:v1 raqssoriano/hha504docker:v1
  • (3) command to push structure:
    • docker push raqssoriano/hha504docker:v1

Create a Container for a Simple Application

Creating a Docker Image:

  1. Using the Cloud Shell Editor, I created a new directory called "docker-hw" and created a file named "app.py". Inside this file, I created a simple flask application that I copied from my professor and modified to make it more personalized. See the python script/code below.

    from flask import Flask, render_template, render_template_string
    import random
    
    app = Flask(__name__)
    
    #@app.route('/')
    #def index():
    #    return "<h1>Life is Beautiful!!! Sending a message from Raqs flask app in a Docker Container! :-)!</h1>"
    
    @app.route('/')
    def index():
       return render_template('index.html') 
    
    if __name__ == '__main__':
       app.run(debug=True, host='0.0.0.0', port='5000')
  2. I built the Docker image on my local machine and tested it to make sure it runs correctly. See the screenshots below how I accomplished this section.

    .

    .

    .

    .

    .

  3. Prior to creating a flask app, I signed up for a new account on Docker Hub by connecting my GitHub account, and created a directory named "raqssoriano". In this directory, I created a repository called "hha540docker". This was instrumental in successfully deploying the flask app I had previously created.

    .

  4. In the Cloud Shell Editor, I created a new file named "dockerfile" in the "docker-hw" directory, which contains instructions on how to create or build a Docker image. This is taken from Professor Hants' HHA-504-2024 GitHub repository.

    FROM python:3.11-alpine
    WORKDIR /app
    COPY . /app
    RUN pip install -r requirements.txt
    EXPOSE 5000
    CMD ["python", "app.py"]

    .



Deployment on GCP Cloud Run

  1. I deployed my Docker image to DockerHub.

    .

  2. I navigated to GCP and searched for Cloud Run in the search bar, and clicked Deploy Container and Service.

    .

  3. I configured the deployment, including setting environment variables and scaling options according to the instructions.

    .

    .

    .

  4. I tested the deployed application to make sure it's running correctly.

    .

    .



Deployment Using Azure Container Apps

  1. I navigated to Azure and searched for Container Apps in the search bar, and created a Container App named "raqs504flask." See the screenshots below.

    .

    .

  2. Similar to GCP Cloud Run, I ensured that the configuration process was completed by creating a resource group called "my504dockerhw."

    .

  3. I deployed the containerized application using the Docker image that I initially pushed or deployed to Docker Hub.

    .

    .

    .

    .

    .

  4. Similar to GCP Cloud Run, I tested the deployed application to make sure it's running correctly.

    .

    .

    .



Reflections on the Deployment Process

  • 📌 GCP Cloud Run:

    • I did not have any issues during the deployment process. It was pretty easy. I have to give credit to Professor Hants' zoom class video recording and the code/script examples in his GitHub repository.
    • Although I wonder if I can do it on my own without guidance from my professor. I would probably have difficulty figuring out which code/script to use in Docker Hub and in attempting to deploy the Docker image to GCP Cloud Run. This might be challenging, but I might consider searching for the correct documentation. If I remember correctly from the recorded video, my professor also looked up the script to be used. This might work for me in the future.
  • 📌 Azure Container App:

    • In step 3, where I attempted to deploy the Docker image from my Docker Hub, this is the part that caused my deployment process to fail multiple times. In Registry Login Server, I initially clicked the information icon (the icon with an "i" that appears after the registry login server field) and followed the example by first typing my Docker Hub username. After watching the YouTube video by Microsoft DevRadio, I left "docker.io" in the registry login server field as it is, then I successfully deployed the container app I created in Azure.
    • I noticed that Azure automatically generates a unique identifier for my newly created container app, as seen in the highlighted application URL, which includes the word "thankfulforest." As compared to GCP, I have the flexibility to create my own unique identifier, although I'm not quite sure if GCP has the same feature as Azure that automatically generates this.
  • 📌 Final Thoughts:

    • If I hadn't had issues with the registry login server field as previously mentioned, I can say that the deployment process was pretty much the same on both platforms, with the creation and deployment steps being easy to follow. With that being said, I like both GCP Cloud Run and Azure Container App. I find this assignment quite enjoyable and interesting because it seems that I can apply my creative side if I gain more experience in figuring out the code/script to use for images or perhaps videos that I want to upload and deploy to a certain portal. When I get more experience, I might apply everything I've learned in this assignment to create a personal or portfolio website to highlight my professional journey and showcase all my work or assignments/projects from grad school. This will provide an interesting way for potential employers to learn about my background and skills or expertise.🤓

About

This task is part of my assignment focused on deploying and managing containers using GCP Cloud Run and Azure Container Apps. I am learning how to containerize an application with Docker and deploy it on both platforms.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors