Difference between revisions of "Docker/C3/Automating-Docker-Builds/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "<div style="margin-left:1.27cm;margin-right:0cm;"></div> {| border="1" |- || '''Visual Cue''' || '''Narration''' |- |- style="border:1pt solid #000000;padding-top:0cm;padding-...")
 
Line 1: Line 1:
<div style="margin-left:1.27cm;margin-right:0cm;"></div>
+
 
 
{| border="1"
 
{| border="1"
 
|-
 
|-
Line 5: Line 5:
 
|| '''Narration'''
 
|| '''Narration'''
 
|-
 
|-
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:  
 
|| Show slide:  
  
 
'''Title Slide'''
 
'''Title Slide'''
 
|| Hello and welcome to the Spoken Tutorial on “'''Automating Docker Builds”.'''
 
|| Hello and welcome to the Spoken Tutorial on “'''Automating Docker Builds”.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide:
 
|| Show Slide:
  
 
'''Learning Objectives'''
 
'''Learning Objectives'''
 
|| In this tutorial, we will learn how to
 
|| In this tutorial, we will learn how to
* <div style="margin-left:1.27cm;margin-right:0cm;">Setup and configure GitHub </div>
+
* Setup and configure GitHub  
* <div style="margin-left:1.27cm;margin-right:0cm;">Automate Docker builds using GitHub</div>
+
* Automate Docker builds using GitHub
* <div style="margin-left:1.27cm;margin-right:0cm;">Pull and test the built images</div>
+
* Pull and test the built images
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide:
 
|| Show Slide:
  
 
'''System Requirements'''
 
'''System Requirements'''
 
|| To record this tutorial, I am using  
 
|| To record this tutorial, I am using  
* <div style="margin-left:1.27cm;margin-right:0cm;">'''Ubuntu Linux '''OS version '''22.04 '''and </div>
+
* '''Ubuntu Linux '''OS version '''22.04 '''and  
* <div style="margin-left:1.27cm;margin-right:0cm;">'''Docker version 27.0.2'''</div>
+
* '''Docker version 27.0.2'''
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide:
 
|| Show Slide:
  
Line 34: Line 34:
 
[https://www.spoken-tutorial.org/ https://www.spoken-tutorial.org]
 
[https://www.spoken-tutorial.org/ https://www.spoken-tutorial.org]
 
|| To follow this tutorial,
 
|| To follow this tutorial,
* <div style="margin-left:1.27cm;margin-right:0cm;">You must have a '''Docker Hub '''account</div>
+
* You must have a '''Docker Hub '''account
* <div style="margin-left:1.27cm;margin-right:0cm;">You must have a '''GitHub''' account</div>
+
* You must have a '''GitHub''' account
  
 
For pre-requisite, please visit the docker series on this website.
 
For pre-requisite, please visit the docker series on this website.
 
|-
 
|-
| style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Show slide:
+
|| Show slide:
 
'''Code files'''
 
'''Code files'''
| style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;" |
+
||
* <div style="margin-left:1.27cm;margin-right:0cm;">The files used in this tutorial are provided in the '''Code files''' link.</div>
+
* The files used in this tutorial are provided in the '''Code files''' link.
* <div style="margin-left:1.27cm;margin-right:0cm;">Please download and extract the files.</div>
+
* Please download and extract the files.
* <div style="margin-left:1.27cm;margin-right:0cm;">Make a copy and then use them while practicing.</div>
+
* Make a copy and then use them while practicing.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:
 
|| Show slide:
  
 
'''Git Setup - Instruction sheet'''
 
'''Git Setup - Instruction sheet'''
 
||  
 
||  
* <div style="margin-left:1.27cm;margin-right:0cm;">The instructions to set up Git are provided in the Additional Reading section of this tutorial</div>
+
* The instructions to set up Git are provided in the Additional Reading section of this tutorial
* <div style="margin-left:1.27cm;margin-right:0cm;">Go through them to install Git and create a GitHub repository for the code files</div>
+
* Go through them to install Git and create a GitHub repository for the code files
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide:
 
|| Show Slide:
  
 
'''GitHub Actions'''
 
'''GitHub Actions'''
 
||
 
||
* <div style="margin-left:1.27cm;margin-right:0cm;">'''GitHub Actions '''is an automation platform.</div>
+
* '''GitHub Actions '''is an automation platform.
* <div style="margin-left:1.27cm;margin-right:0cm;">It helps automate software development workflows within '''GitHub '''repositories.</div>
+
* It helps automate software development workflows within '''GitHub '''repositories.
* <div style="margin-left:1.27cm;margin-right:0cm;">It runs workflows when code is committed.</div>
+
* It runs workflows when code is committed.
* <div style="margin-left:1.27cm;margin-right:0cm;">Workflows automatically build and test the code.</div>
+
* Workflows automatically build and test the code.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:'''GitHub Actions Flowchartn'''
 
|| Show slide:'''GitHub Actions Flowchartn'''
 
|| This flowchart shows the process of automating building '''Docker '''images.
 
|| This flowchart shows the process of automating building '''Docker '''images.
Line 68: Line 68:
 
We shall be building a custom '''Docker '''image for an '''Express '''web server.
 
We shall be building a custom '''Docker '''image for an '''Express '''web server.
  
<div style="color:#000000;">The code is similar to the one we demonstrated earlier.</div>
+
The code is similar to the one we demonstrated earlier.
  
<div style="color:#000000;">Previously, we built the image manually using '''Docker build '''command.</div>
+
Previously, we built the image manually using '''Docker build '''command.
  
 
Now, we will automate the process using '''GitHub Actions'''.
 
Now, we will automate the process using '''GitHub Actions'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:'''GitHub Actions Flowchart'''
 
|| Show slide:'''GitHub Actions Flowchart'''
 
|| The application will run an '''Express web server'''.
 
|| The application will run an '''Express web server'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:'''GitHub Actions Flowchart'''
 
|| Show slide:'''GitHub Actions Flowchart'''
 
|| The '''Dockerfile '''will be the same as the one used previously.
 
|| The '''Dockerfile '''will be the same as the one used previously.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:'''GitHub Actions Flowchart'''
 
|| Show slide:'''GitHub Actions Flowchart'''
  
 
|| We will push the application code and '''Dockerfile '''to '''GitHub'''.
 
|| We will push the application code and '''Dockerfile '''to '''GitHub'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:'''GitHub Actions Flowchart'''
 
|| Show slide:'''GitHub Actions Flowchart'''
 
|| Then we will set up '''GitHub Actions '''for building the image.
 
|| Then we will set up '''GitHub Actions '''for building the image.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:'''GitHub Actions Flowchart'''
 
|| Show slide:'''GitHub Actions Flowchart'''
 
|| Then '''GitHub Actions '''will automatically build the image.
 
|| Then '''GitHub Actions '''will automatically build the image.
 
The image will be built everytime code is pushed to '''GitHub'''.
 
The image will be built everytime code is pushed to '''GitHub'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:'''GitHub Actions Flowchart'''
 
|| Show slide:'''GitHub Actions Flowchart'''
 
|| The built image will be automatically pushed to '''Docker Hub'''.
 
|| The built image will be automatically pushed to '''Docker Hub'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:'''GitHub Actions Flowchart'''
 
|| Show slide:'''GitHub Actions Flowchart'''
  
 
|| Then the image can be pulled from '''Docker Hub '''and used.
 
|| Then the image can be pulled from '''Docker Hub '''and used.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
||  
 
||  
 
|| Let us see how it works.
 
|| Let us see how it works.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Open the '''Code Files '''directory in file manager.
 
|| Open the '''Code Files '''directory in file manager.
 
|| I have already created the code files for this tutorial.
 
|| I have already created the code files for this tutorial.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight the folder '''node-express''' and open it.
 
|| Highlight the folder '''node-express''' and open it.
 
|| Open the folder '''node hyphen express'''.
 
|| Open the folder '''node hyphen express'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight the folder '''express_api'''.
 
|| Highlight the folder '''express_api'''.
  
Line 119: Line 119:
  
 
The '''quotes dot js '''file contains a list of quotations.
 
The '''quotes dot js '''file contains a list of quotations.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight the file '''gitignore'''
 
|| Highlight the file '''gitignore'''
 
|| The '''gitignore '''file lists the files that are not to be pushed to '''GitHub'''.
 
|| The '''gitignore '''file lists the files that are not to be pushed to '''GitHub'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Open Firefox web browser.
 
|| Open Firefox web browser.
  
Line 129: Line 129:
  
 
Push the directory '''express underscore api '''and the '''Dockerfile''' as given in the instruction sheet.
 
Push the directory '''express underscore api '''and the '''Dockerfile''' as given in the instruction sheet.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Open a new browser tab.
 
|| Open a new browser tab.
  
Line 142: Line 142:
  
 
If this page does not appear, check if you are logged in.
 
If this page does not appear, check if you are logged in.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Hover over '''node-express '''in the list of Docker images.
 
|| Hover over '''node-express '''in the list of Docker images.
 
|| I have already created a repository for the image '''node hyphen express'''.
 
|| I have already created a repository for the image '''node hyphen express'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the user icon on the top right of the website.
 
|| Click on the user icon on the top right of the website.
 
|| Click on the user icon on the top right of the '''Docker Hub '''website.
 
|| Click on the user icon on the top right of the '''Docker Hub '''website.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on '''Account settings '''in the dropdown menu.
 
|| Click on '''Account settings '''in the dropdown menu.
 
|| In the drop down menu, click on '''Account settings '''to open''' '''the '''Settings '''page'''.'''
 
|| In the drop down menu, click on '''Account settings '''to open''' '''the '''Settings '''page'''.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Under '''Security, '''click on '''Personal access tokens'''.
 
|| Under '''Security, '''click on '''Personal access tokens'''.
 
|| Under '''Security, '''click on '''Personal access tokens'''.
 
|| Under '''Security, '''click on '''Personal access tokens'''.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the '''Generate new token '''button.
 
|| Click on the '''Generate new token '''button.
 
|| Click on the '''Generate new token '''button.
 
|| Click on the '''Generate new token '''button.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| In the '''Access token description '''field, type '''GitHub Actions'''.
 
|| In the '''Access token description '''field, type '''GitHub Actions'''.
 
Highlight '''GitHub Actions'''.
 
Highlight '''GitHub Actions'''.
 
|| In the '''Access token description '''field, type '''GitHub Actions'''.
 
|| In the '''Access token description '''field, type '''GitHub Actions'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| In the '''Access permissions '''dropdown, select '''Read & Write'''  
 
|| In the '''Access permissions '''dropdown, select '''Read & Write'''  
 
|| In the '''Access permissions '''dropdown, select '''Read and Write'''.
 
|| In the '''Access permissions '''dropdown, select '''Read and Write'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the '''Generate '''button.
 
|| Click on the '''Generate '''button.
 
|| Click on the '''Generate '''button.
 
|| Click on the '''Generate '''button.
Line 173: Line 173:
 
This will generate an '''Access Token''' which helps other applications to access '''Docker Hub'''.
 
This will generate an '''Access Token''' which helps other applications to access '''Docker Hub'''.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Copy access token'''.
 
|| Highlight '''Copy access token'''.
 
|| A new screen will appear with the title '''Copy access token'''.
 
|| A new screen will appear with the title '''Copy access token'''.
  
 
Here we will copy our access token.
 
Here we will copy our access token.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the '''Copy '''button next to the access token in the second code box.  
 
|| Click on the '''Copy '''button next to the access token in the second code box.  
 
|| Click on the '''Copy '''button next to the access token in the second code box.  
 
|| Click on the '''Copy '''button next to the access token in the second code box.  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Switch to the browser tab where '''GitHub '''is open.
 
|| Switch to the browser tab where '''GitHub '''is open.
 
|| Now switch to the '''GitHub '''browser tab.
 
|| Now switch to the '''GitHub '''browser tab.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the '''Settings '''tab on the ribbon below the username.
 
|| Click on the '''Settings '''tab on the ribbon below the username.
  
Line 190: Line 190:
  
 
Click on the '''Settings '''tab on the menu bar below the username.
 
Click on the '''Settings '''tab on the menu bar below the username.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| On the left sidebar, expand '''Secrets and variables''' by clicking on it.
 
|| On the left sidebar, expand '''Secrets and variables''' by clicking on it.
 
|| On the left sidebar, expand '''Secrets and variables''' by clicking on it.
 
|| On the left sidebar, expand '''Secrets and variables''' by clicking on it.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on '''Actions'''.
 
|| Click on '''Actions'''.
  
Line 200: Line 200:
  
 
The '''Actions secrets and variables '''page will open.
 
The '''Actions secrets and variables '''page will open.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the '''Variables '''tab.
 
|| Click on the '''Variables '''tab.
 
|| Now click on the '''Variables '''tab.
 
|| Now click on the '''Variables '''tab.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Under the Repository''' variables '''section, click on the '''New repository variable '''button.
 
|| Under the Repository''' variables '''section, click on the '''New repository variable '''button.
 
|| Under the '''Repository variables '''section, click on the '''New repository variable '''button.
 
|| Under the '''Repository variables '''section, click on the '''New repository variable '''button.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| In the '''Name '''field type '''DOCKER_USERNAME'''.
 
|| In the '''Name '''field type '''DOCKER_USERNAME'''.
 
|| Type '''DOCKER underscore USERNAME '''in the '''Name '''field.
 
|| Type '''DOCKER underscore USERNAME '''in the '''Name '''field.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| In the '''Value '''field type your '''Docker Hub''' username.
 
|| In the '''Value '''field type your '''Docker Hub''' username.
 
|| In the '''Value '''field type your '''Docker Hub''' username as shown.
 
|| In the '''Value '''field type your '''Docker Hub''' username as shown.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the '''Add variable '''button.
 
|| Click on the '''Add variable '''button.
 
|| Click on the '''Add variable '''button.
 
|| Click on the '''Add variable '''button.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''DOCKER_USERNAME'''
 
|| Highlight '''DOCKER_USERNAME'''
 
|| This variable will be used in our '''GitHub Actions '''workflow file for username.
 
|| This variable will be used in our '''GitHub Actions '''workflow file for username.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the '''Secrets '''tab.
 
|| Click on the '''Secrets '''tab.
 
|| Click on the '''Secrets '''tab.
 
|| Click on the '''Secrets '''tab.
  
 
Since '''Access Tokens '''need to be secured, we will use '''GitHub Secrets'''.
 
Since '''Access Tokens '''need to be secured, we will use '''GitHub Secrets'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the '''New repository secret''' button.
 
|| Click on the '''New repository secret''' button.
  
 
Highlight '''Actions secrets/New secret'''
 
Highlight '''Actions secrets/New secret'''
 
|| Click on the '''New repository secret '''button.
 
|| Click on the '''New repository secret '''button.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| In the '''Name '''field, type '''DOCKERHUB_TOKEN'''.
 
|| In the '''Name '''field, type '''DOCKERHUB_TOKEN'''.
 
|| In the '''Name '''field, type '''DOCKERHUB underscore TOKEN'''.
 
|| In the '''Name '''field, type '''DOCKERHUB underscore TOKEN'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| In the '''Secret '''field, paste the '''access token '''by pressing '''Ctrl and V '''keys simultaneously.
 
|| In the '''Secret '''field, paste the '''access token '''by pressing '''Ctrl and V '''keys simultaneously.
 
|| In the '''Secret '''field, paste the '''access token '''by pressing '''Ctrl and V '''keys simultaneously.
 
|| In the '''Secret '''field, paste the '''access token '''by pressing '''Ctrl and V '''keys simultaneously.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the '''Add secret '''button.
 
|| Click on the '''Add secret '''button.
 
|| Click on the '''Add secret''' button.
 
|| Click on the '''Add secret''' button.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Only narration.
 
|| Only narration.
 
|| We have created a '''Docker Hub '''token and added it to '''GitHub '''secret.
 
|| We have created a '''Docker Hub '''token and added it to '''GitHub '''secret.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Only narration.
 
|| Only narration.
 
|| Next we will set up '''GitHub Actions.'''
 
|| Next we will set up '''GitHub Actions.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the '''Actions '''tab in the ribbon below the username.
 
|| Click on the '''Actions '''tab in the ribbon below the username.
 
|| Click on the '''Actions '''tab in the menu bar  
 
|| Click on the '''Actions '''tab in the menu bar  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on '''set up a workflow yourself '''link.
 
|| Click on '''set up a workflow yourself '''link.
 
|| Click on '''set up a workflow yourself '''link.
 
|| Click on '''set up a workflow yourself '''link.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Only narration.
 
|| Only narration.
 
|| If you previously created a workflow, the link may not appear.
 
|| If you previously created a workflow, the link may not appear.
Line 256: Line 256:
  
 
Then click on the '''set up a workflow yourself '''link.
 
Then click on the '''set up a workflow yourself '''link.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Only narration.
 
|| Only narration.
 
|| A new page will open with an empty code editor window.
 
|| A new page will open with an empty code editor window.
  
 
We will add code to this editor from the code files.
 
We will add code to this editor from the code files.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Switch to file manager ('''Nautilus).'''
 
|| Switch to file manager ('''Nautilus).'''
  
Line 268: Line 268:
  
 
Copy the complete code and paste in the editor in the '''GitHub '''tab.
 
Copy the complete code and paste in the editor in the '''GitHub '''tab.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''name: Docker Image Build'''
 
|| Highlight '''name: Docker Image Build'''
 
|| The code follows the '''YAML '''syntax.
 
|| The code follows the '''YAML '''syntax.
  
 
The '''name '''key defines the '''workflow '''name '''Docker Image Build'''.
 
The '''name '''key defines the '''workflow '''name '''Docker Image Build'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''on'''.
 
|| Highlight '''on'''.
 
|| The '''on '''key specifies the events on which the script will run.
 
|| The '''on '''key specifies the events on which the script will run.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''push'''
 
|| Highlight '''push'''
 
|| The '''push '''key indicates that the script will run when code is pushed.
 
|| The '''push '''key indicates that the script will run when code is pushed.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''branches:'''
 
|| Highlight '''branches:'''
  
Line 285: Line 285:
  
 
|| The script runs only for the '''main '''branch.
 
|| The script runs only for the '''main '''branch.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''build'''
 
|| Highlight '''build'''
 
|| We define one job named '''build''' for building the '''Docker image.'''
 
|| We define one job named '''build''' for building the '''Docker image.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''runs-on:ubuntu-latest'''
 
|| Highlight '''runs-on:ubuntu-latest'''
 
|| '''Ubuntu hyphen latest '''denotes the operating system to run the image.
 
|| '''Ubuntu hyphen latest '''denotes the operating system to run the image.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''steps'''
 
|| Highlight '''steps'''
 
|| The '''steps '''key defines the steps that will be followed in the job.
 
|| The '''steps '''key defines the steps that will be followed in the job.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''name: Login to Docker Hub'''
 
|| Highlight '''name: Login to Docker Hub'''
 
|| The step '''Login to Docker Hub '''logs in to '''Docker Hub'''.
 
|| The step '''Login to Docker Hub '''logs in to '''Docker Hub'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''uses: docker/login-action@v3'''
 
|| Highlight '''uses: docker/login-action@v3'''
 
|| The '''login-action''' action performs login using the '''username '''and '''access token'''.
 
|| The '''login-action''' action performs login using the '''username '''and '''access token'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''username: ${{ vars.DOCKER_USERNAME }}'''
 
|| Highlight '''username: ${{ vars.DOCKER_USERNAME }}'''
  
 
|| Then we set the value of the username to '''docker underscore username '''variable'''.'''
 
|| Then we set the value of the username to '''docker underscore username '''variable'''.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''password: ${{ secrets.DOCKERHUB_TOKEN }}'''
 
|| Highlight '''password: ${{ secrets.DOCKERHUB_TOKEN }}'''
 
|| Similarly we set the value of the password to '''dockerhub underscore token '''secret.
 
|| Similarly we set the value of the password to '''dockerhub underscore token '''secret.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''name: Set up Docker Buildx'''
 
|| Highlight '''name: Set up Docker Buildx'''
 
|| '''Docker buildx plugin '''helps in building Docker images.
 
|| '''Docker buildx plugin '''helps in building Docker images.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''uses: docker/setup-buildx-action@v3'''
 
|| Highlight '''uses: docker/setup-buildx-action@v3'''
 
|| We use the action '''setup hyphen buildx hyphen action'''.
 
|| We use the action '''setup hyphen buildx hyphen action'''.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''name: Build and push'''
 
|| Highlight '''name: Build and push'''
 
|| The next step is building the image and pushing it to '''Docker Hub.'''
 
|| The next step is building the image and pushing it to '''Docker Hub.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''uses: docker/build-push-action@v6'''
 
|| Highlight '''uses: docker/build-push-action@v6'''
 
|| Here we use the version 6 of '''build hyphen push hyphen action'''  
 
|| Here we use the version 6 of '''build hyphen push hyphen action'''  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight''' push: true '''
 
|| Highlight''' push: true '''
 
|| '''Push colon true''' denotes that the image will be pushed to '''Docker Hub.'''
 
|| '''Push colon true''' denotes that the image will be pushed to '''Docker Hub.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''tags: ${{ vars.DOCKER_USERNAME }}/node-express:latest'''
 
|| Highlight '''tags: ${{ vars.DOCKER_USERNAME }}/node-express:latest'''
 
|| The '''tags '''key specifies the tags to be added for locating the image in '''Docker Hub.'''
 
|| The '''tags '''key specifies the tags to be added for locating the image in '''Docker Hub.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''vars.DOCKER_USERNAME'''
 
|| Highlight '''vars.DOCKER_USERNAME'''
 
|| The first part of our tag is our '''Docker Hub '''username.
 
|| The first part of our tag is our '''Docker Hub '''username.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''node-express:latest'''
 
|| Highlight '''node-express:latest'''
  
Line 335: Line 335:
  
 
'''colon latest '''is used to denote that the build is the latest build.
 
'''colon latest '''is used to denote that the build is the latest build.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on '''Commit changes '''button
 
|| Click on '''Commit changes '''button
 
|| Click on '''Commit changes '''button on the top right corner under the menu bar.
 
|| Click on '''Commit changes '''button on the top right corner under the menu bar.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on '''Commit changes '''button at the bottom of the dialog box  
 
|| Click on '''Commit changes '''button at the bottom of the dialog box  
 
|| In the dialog box, click on the '''Commit changes '''button.
 
|| In the dialog box, click on the '''Commit changes '''button.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the '''Actions '''tab on the top ribbon.
 
|| Click on the '''Actions '''tab on the top ribbon.
 
|| Click on the '''Actions '''tab on the menu bar.
 
|| Click on the '''Actions '''tab on the menu bar.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Hover over '''Create main.yml '''under '''All workflows'''.
 
|| Hover over '''Create main.yml '''under '''All workflows'''.
 
|| A new workflow run will appear under '''All workflows''' called '''Create main dot yml'''..
 
|| A new workflow run will appear under '''All workflows''' called '''Create main dot yml'''..
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Hover on the yellow progress circle on the left of '''Create main.yaml'''.
 
|| Hover on the yellow progress circle on the left of '''Create main.yaml'''.
  
Line 355: Line 355:
  
 
Wait for the build process to complete.
 
Wait for the build process to complete.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Hover on the green tick mark on the left of '''Create main.yml'''.
 
|| Hover on the green tick mark on the left of '''Create main.yml'''.
 
|| The build process is now completed which is indicated by a green tick mark.
 
|| The build process is now completed which is indicated by a green tick mark.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Open another browser tab and visit the URL [https://hub.docker.com/ https://hub.docker.com]
 
|| Open another browser tab and visit the URL [https://hub.docker.com/ https://hub.docker.com]
 
|| Now open another browser tab and visit the following URL to '''Docker Hub.'''.
 
|| Now open another browser tab and visit the following URL to '''Docker Hub.'''.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on '''Repositories '''on the top ribbon.
 
|| Click on '''Repositories '''on the top ribbon.
 
|| Click on '''Repositories '''on the top menu bar.
 
|| Click on '''Repositories '''on the top menu bar.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the '''node-express '''repository.
 
|| Click on the '''node-express '''repository.
 
|| Click on the '''node hyphen express '''repository.
 
|| Click on the '''node hyphen express '''repository.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Under '''Tags, '''hover over '''latest'''.
 
|| Under '''Tags, '''hover over '''latest'''.
 
|| An image with the latest''' '''tag is available here.
 
|| An image with the latest''' '''tag is available here.
  
 
This was created and pushed by the '''GitHub Actions '''build process.
 
This was created and pushed by the '''GitHub Actions '''build process.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Only narration.
 
|| Only narration.
 
|| Now we will sync our local code with the '''GitHub '''repository.
 
|| Now we will sync our local code with the '''GitHub '''repository.
  
 
This is required since we added the '''GitHub Actions '''file.
 
This is required since we added the '''GitHub Actions '''file.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Switch to the terminal window.
 
|| Switch to the terminal window.
 
|| Switch to the terminal window.
 
|| Switch to the terminal window.
  
 
Make sure that you are in the''' node-express '''directory in the terminal.
 
Make sure that you are in the''' node-express '''directory in the terminal.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Type '''git pull origin main'''.
 
|| Type '''git pull origin main'''.
  
Line 392: Line 392:
  
 
Make sure this is the same directory from which you push the code to the github.
 
Make sure this is the same directory from which you push the code to the github.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''1 file changed, 26 insertions(+)'''
 
|| Highlight '''1 file changed, 26 insertions(+)'''
  
 
Highlight '''create mode 100644 .github/workflows/main.yml'''
 
Highlight '''create mode 100644 .github/workflows/main.yml'''
 
|| The output shows that our file '''main dot yml''' was fetched.
 
|| The output shows that our file '''main dot yml''' was fetched.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Only narration.
 
|| Only narration.
 
|| Now we will enable the API in our code that is disabled.
 
|| Now we will enable the API in our code that is disabled.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Open the file '''app.js '''in the text editor.
 
|| Open the file '''app.js '''in the text editor.
 
|| Open the file '''app dot js '''in the text editor.
 
|| Open the file '''app dot js '''in the text editor.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''app.get('/quote', async (req, res) => {'''
 
|| Highlight '''app.get('/quote', async (req, res) => {'''
  
Line 410: Line 410:
 
'''})'''
 
'''})'''
 
|| We will uncomment this code to enable the API
 
|| We will uncomment this code to enable the API
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Save the file by pressing '''Ctrl '''and '''S '''keys simultaneously.
 
|| Save the file by pressing '''Ctrl '''and '''S '''keys simultaneously.
 
|| Save the file by pressing '''Ctrl '''and '''S '''keys simultaneously.
 
|| Save the file by pressing '''Ctrl '''and '''S '''keys simultaneously.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Only narration.
 
|| Only narration.
 
|| Now we will push the code to '''GitHub'''.  
 
|| Now we will push the code to '''GitHub'''.  
  
 
Then, an image will be automatically built by '''GitHub Actions.'''
 
Then, an image will be automatically built by '''GitHub Actions.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Switch to the terminal window.
 
|| Switch to the terminal window.
 
|| Switch to the terminal window.
 
|| Switch to the terminal window.
  
 
Make sure that you are in the''' node-express '''directory .
 
Make sure that you are in the''' node-express '''directory .
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Type '''git add . '''and press Enter.
 
|| Type '''git add . '''and press Enter.
 
|| Type '''git space add space dot '''and press Enter.
 
|| Type '''git space add space dot '''and press Enter.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Type '''git commit -m "Enabled API"''' and press Enter.
 
|| Type '''git commit -m "Enabled API"''' and press Enter.
 
|| To commit the changes, type the command as shown.
 
|| To commit the changes, type the command as shown.
  
 
Press Enter
 
Press Enter
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Type '''git push origin main '''and press '''Enter.'''
 
|| Type '''git push origin main '''and press '''Enter.'''
 
|| Type '''git space push space origin space main '''and press '''Enter'''.
 
|| Type '''git space push space origin space main '''and press '''Enter'''.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''main -> main '''in the command output.
 
|| Highlight '''main -> main '''in the command output.
 
|| Now our code is pushed to '''GitHub.'''
 
|| Now our code is pushed to '''GitHub.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Switch to the browser tab where '''GitHub '''is open.
 
|| Switch to the browser tab where '''GitHub '''is open.
 
|| Switch to the browser tab where '''GitHub '''is open.
 
|| Switch to the browser tab where '''GitHub '''is open.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Enabled API''' under '''Actions '''tab.
 
|| Highlight '''Enabled API''' under '''Actions '''tab.
 
|| You will see a job workflow run named '''Enabled API, '''shown by the yellow circle'''.'''
 
|| You will see a job workflow run named '''Enabled API, '''shown by the yellow circle'''.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight green tick mark on the left of '''Enabled API.'''
 
|| Highlight green tick mark on the left of '''Enabled API.'''
 
|| The build is completed, which is denoted by the green tick mark
 
|| The build is completed, which is denoted by the green tick mark
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Only narration
 
|| Only narration
 
|| Now we will pull the latest image on '''Docker Hub '''with the changes we did.
 
|| Now we will pull the latest image on '''Docker Hub '''with the changes we did.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Switch to the terminal window.
 
|| Switch to the terminal window.
 
|| Switch to the terminal window.
 
|| Switch to the terminal window.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Type '''sudo docker pull '''['''docker hub username]/node-express:latest'''
 
|| Type '''sudo docker pull '''['''docker hub username]/node-express:latest'''
  
Line 465: Line 465:
  
 
Press Enter.
 
Press Enter.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Enter password for root account and press Enter.
 
|| Enter password for root account and press Enter.
 
|| Enter password if prompted and press Enter.
 
|| Enter password if prompted and press Enter.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Wait for the download to complete.
 
|| Wait for the download to complete.
 
|| Wait for the download to complete.
 
|| Wait for the download to complete.
  
 
It can take some time depending on your internet speed.
 
It can take some time depending on your internet speed.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Only narration.
 
|| Only narration.
 
|| Let us now run this image.
 
|| Let us now run this image.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Type '''sudo docker run -d -p 127.0.0.1:3000:3000 [docker hub username]/node-express:latest'''.
 
|| Type '''sudo docker run -d -p 127.0.0.1:3000:3000 [docker hub username]/node-express:latest'''.
  
Line 487: Line 487:
  
 
Press Enter.
 
Press Enter.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Open a new browser tab.
 
|| Open a new browser tab.
  
Line 498: Line 498:
  
 
Press Enter.
 
Press Enter.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight the text on the screen.
 
|| Highlight the text on the screen.
 
|| A random quote is displayed.
 
|| A random quote is displayed.
Line 504: Line 504:
 
This confirms that the image was successfully updated in '''Docker Hub'''.
 
This confirms that the image was successfully updated in '''Docker Hub'''.
 
|-
 
|-
| style="border-top:1pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | Show Slide:
+
|| Show Slide:
  
 
'''Summary'''
 
'''Summary'''
| style="border-top:1pt solid #000000;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;" | This brings us to the end of this tutorial. Let us summarise.
+
|| This brings us to the end of this tutorial. Let us summarise.
  
 
In this tutorial, we have learnt how to
 
In this tutorial, we have learnt how to
* <div style="margin-left:1.27cm;margin-right:0cm;">Setup and configure GitHub </div>
+
* Setup and configure GitHub  
* <div style="margin-left:1.27cm;margin-right:0cm;">Automate Docker builds using GitHub</div>
+
* Automate Docker builds using GitHub
* <div style="margin-left:1.27cm;margin-right:0cm;">Pull and test the built images</div>
+
* Pull and test the built images
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide: '''About Spoken Tutorial project'''
 
|| Show Slide: '''About Spoken Tutorial project'''
 
|| The video at the following link summarizes the '''Spoken Tutorial project'''.
 
|| The video at the following link summarizes the '''Spoken Tutorial project'''.
Line 520: Line 520:
 
Please download and watch it
 
Please download and watch it
 
|-
 
|-
| style="background-color:#ffffff;border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.095cm;padding-right:0.191cm;" | Show Slide: '''Spoken Tutorial Workshops'''
+
|| Show Slide:  
| style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.079cm;padding-right:0.191cm;" | <span style="background-color:#ffffff;">The&nbsp;</span><span style="background-color:#ffffff;">'''Spoken Tutorial Project'''</span><span style="background-color:#ffffff;">&nbsp;team </span>conducts workshops and gives certificates.
+
 
 +
'''Spoken Tutorial Workshops'''
 +
|| The&nbsp;'''Spoken Tutorial Project'''&nbsp;team conducts workshops and gives certificates.
  
 
For more details, please write to us.
 
For more details, please write to us.
|- style="background-color:#ffffff;border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.095cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide:
 
|| Show Slide:
  
 
'''Answers for THIS Spoken Tutorial'''
 
'''Answers for THIS Spoken Tutorial'''
 
|| Please post your timed queries in this forum.
 
|| Please post your timed queries in this forum.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
|| Show Slide: '''FOSSEE Forum'''
+
|| Show Slide:  
 +
 
 +
'''FOSSEE Forum'''
 
|| For any general or technical questions on '''Docker''', visit the FOSSEE forum and post your question.
 
|| For any general or technical questions on '''Docker''', visit the FOSSEE forum and post your question.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
|| Slide: '''Acknowledgement'''
+
|| Slide:  
 +
 
 +
'''Acknowledgement'''
  
 
|| Spoken Tutorial Project was established by the Ministry of Education, Government of India
 
|| Spoken Tutorial Project was established by the Ministry of Education, Government of India
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.092cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:
 
|| Show slide:
  

Revision as of 17:41, 28 January 2025

Visual Cue Narration
Show slide:

Title Slide

Hello and welcome to the Spoken Tutorial on “Automating Docker Builds”.
Show Slide:

Learning Objectives

In this tutorial, we will learn how to
  • Setup and configure GitHub
  • Automate Docker builds using GitHub
  • Pull and test the built images
Show Slide:

System Requirements

To record this tutorial, I am using
  • Ubuntu Linux OS version 22.04 and
  • Docker version 27.0.2
Show Slide:

Prerequisite

https://www.spoken-tutorial.org

To follow this tutorial,
  • You must have a Docker Hub account
  • You must have a GitHub account

For pre-requisite, please visit the docker series on this website.

Show slide:

Code files

  • The files used in this tutorial are provided in the Code files link.
  • Please download and extract the files.
  • Make a copy and then use them while practicing.
Show slide:

Git Setup - Instruction sheet

  • The instructions to set up Git are provided in the Additional Reading section of this tutorial
  • Go through them to install Git and create a GitHub repository for the code files
Show Slide:

GitHub Actions

  • GitHub Actions is an automation platform.
  • It helps automate software development workflows within GitHub repositories.
  • It runs workflows when code is committed.
  • Workflows automatically build and test the code.
Show slide:GitHub Actions Flowchartn This flowchart shows the process of automating building Docker images.

We shall be building a custom Docker image for an Express web server.

The code is similar to the one we demonstrated earlier.

Previously, we built the image manually using Docker build command.

Now, we will automate the process using GitHub Actions.

Show slide:GitHub Actions Flowchart The application will run an Express web server.
Show slide:GitHub Actions Flowchart The Dockerfile will be the same as the one used previously.
Show slide:GitHub Actions Flowchart We will push the application code and Dockerfile to GitHub.
Show slide:GitHub Actions Flowchart Then we will set up GitHub Actions for building the image.
Show slide:GitHub Actions Flowchart Then GitHub Actions will automatically build the image.

The image will be built everytime code is pushed to GitHub.

Show slide:GitHub Actions Flowchart The built image will be automatically pushed to Docker Hub.
Show slide:GitHub Actions Flowchart Then the image can be pulled from Docker Hub and used.
Let us see how it works.
Open the Code Files directory in file manager. I have already created the code files for this tutorial.
Highlight the folder node-express and open it. Open the folder node hyphen express.
Highlight the folder express_api.

Open the express_api folder.

The folder express underscore api contains the files for the application.

The Dockerfile contains the instructions for building an image.

The app dot js file contains the code for the Express web server.

The quotes dot js file contains a list of quotations.

Highlight the file gitignore The gitignore file lists the files that are not to be pushed to GitHub.
Open Firefox web browser.

Navigate to the URL: https://github.com/your-username/node-express

I have already created a GitHub repository node hyphen express.

Push the directory express underscore api and the Dockerfile as given in the instruction sheet.

Open a new browser tab.

In the search bar, type https://hub.docker.com.

Press Enter.

Open a new browser tab.

In the search bar, type the address as shown.

Your repositories on Docker Hub will appear.

If this page does not appear, check if you are logged in.

Hover over node-express in the list of Docker images. I have already created a repository for the image node hyphen express.
Click on the user icon on the top right of the website. Click on the user icon on the top right of the Docker Hub website.
Click on Account settings in the dropdown menu. In the drop down menu, click on Account settings to open the Settings page.
Under Security, click on Personal access tokens. Under Security, click on Personal access tokens.
Click on the Generate new token button. Click on the Generate new token button.
In the Access token description field, type GitHub Actions.

Highlight GitHub Actions.

In the Access token description field, type GitHub Actions.
In the Access permissions dropdown, select Read & Write In the Access permissions dropdown, select Read and Write.
Click on the Generate button. Click on the Generate button.

This will generate an Access Token which helps other applications to access Docker Hub.

Highlight Copy access token. A new screen will appear with the title Copy access token.

Here we will copy our access token.

Click on the Copy button next to the access token in the second code box. Click on the Copy button next to the access token in the second code box.
Switch to the browser tab where GitHub is open. Now switch to the GitHub browser tab.
Click on the Settings tab on the ribbon below the username. Make sure you are inside the node hyphen express repository.

Click on the Settings tab on the menu bar below the username.

On the left sidebar, expand Secrets and variables by clicking on it. On the left sidebar, expand Secrets and variables by clicking on it.
Click on Actions.

Highlight Actions secrets and variables.

Click on Actions.

The Actions secrets and variables page will open.

Click on the Variables tab. Now click on the Variables tab.
Under the Repository variables section, click on the New repository variable button. Under the Repository variables section, click on the New repository variable button.
In the Name field type DOCKER_USERNAME. Type DOCKER underscore USERNAME in the Name field.
In the Value field type your Docker Hub username. In the Value field type your Docker Hub username as shown.
Click on the Add variable button. Click on the Add variable button.
Highlight DOCKER_USERNAME This variable will be used in our GitHub Actions workflow file for username.
Click on the Secrets tab. Click on the Secrets tab.

Since Access Tokens need to be secured, we will use GitHub Secrets.

Click on the New repository secret button.

Highlight Actions secrets/New secret

Click on the New repository secret button.
In the Name field, type DOCKERHUB_TOKEN. In the Name field, type DOCKERHUB underscore TOKEN.
In the Secret field, paste the access token by pressing Ctrl and V keys simultaneously. In the Secret field, paste the access token by pressing Ctrl and V keys simultaneously.
Click on the Add secret button. Click on the Add secret button.
Only narration. We have created a Docker Hub token and added it to GitHub secret.
Only narration. Next we will set up GitHub Actions.
Click on the Actions tab in the ribbon below the username. Click on the Actions tab in the menu bar
Click on set up a workflow yourself link. Click on set up a workflow yourself link.
Only narration. If you previously created a workflow, the link may not appear.

In that case, click on the New workflow button in the sidebar.

Then click on the set up a workflow yourself link.

Only narration. A new page will open with an empty code editor window.

We will add code to this editor from the code files.

Switch to file manager (Nautilus).

Open the GitHub-Actions-Script.txt file from Code Files in the text editor.

From the code files, open the file GitHub hyphen Actions hyphen Script dot txt.

Copy the complete code and paste in the editor in the GitHub tab.

Highlight name: Docker Image Build The code follows the YAML syntax.

The name key defines the workflow name Docker Image Build.

Highlight on. The on key specifies the events on which the script will run.
Highlight push The push key indicates that the script will run when code is pushed.
Highlight branches:

- main

The script runs only for the main branch.
Highlight build We define one job named build for building the Docker image.
Highlight runs-on:ubuntu-latest Ubuntu hyphen latest denotes the operating system to run the image.
Highlight steps The steps key defines the steps that will be followed in the job.
Highlight name: Login to Docker Hub The step Login to Docker Hub logs in to Docker Hub.
Highlight uses: docker/login-action@v3 The login-action action performs login using the username and access token.
Highlight username: $Template:Vars.DOCKER USERNAME Then we set the value of the username to docker underscore username variable.
Highlight password: $Template:Secrets.DOCKERHUB TOKEN Similarly we set the value of the password to dockerhub underscore token secret.
Highlight name: Set up Docker Buildx Docker buildx plugin helps in building Docker images.
Highlight uses: docker/setup-buildx-action@v3 We use the action setup hyphen buildx hyphen action.
Highlight name: Build and push The next step is building the image and pushing it to Docker Hub.
Highlight uses: docker/build-push-action@v6 Here we use the version 6 of build hyphen push hyphen action
Highlight push: true Push colon true denotes that the image will be pushed to Docker Hub.
Highlight tags: $Template:Vars.DOCKER USERNAME/node-express:latest The tags key specifies the tags to be added for locating the image in Docker Hub.
Highlight vars.DOCKER_USERNAME The first part of our tag is our Docker Hub username.
Highlight node-express:latest node hyphen express is the name of our repository.

colon latest is used to denote that the build is the latest build.

Click on Commit changes button Click on Commit changes button on the top right corner under the menu bar.
Click on Commit changes button at the bottom of the dialog box In the dialog box, click on the Commit changes button.
Click on the Actions tab on the top ribbon. Click on the Actions tab on the menu bar.
Hover over Create main.yml under All workflows. A new workflow run will appear under All workflows called Create main dot yml..
Hover on the yellow progress circle on the left of Create main.yaml.

Wait for the green tick mark to appear.

This yellow circle denotes that the build process is running.

Wait for the build process to complete.

Hover on the green tick mark on the left of Create main.yml. The build process is now completed which is indicated by a green tick mark.
Open another browser tab and visit the URL https://hub.docker.com Now open another browser tab and visit the following URL to Docker Hub..
Click on Repositories on the top ribbon. Click on Repositories on the top menu bar.
Click on the node-express repository. Click on the node hyphen express repository.
Under Tags, hover over latest. An image with the latest tag is available here.

This was created and pushed by the GitHub Actions build process.

Only narration. Now we will sync our local code with the GitHub repository.

This is required since we added the GitHub Actions file.

Switch to the terminal window. Switch to the terminal window.

Make sure that you are in the node-express directory in the terminal.

Type git pull origin main.

Press Enter.

Now type git space pull space origin space main.

Press Enter.

Make sure this is the same directory from which you push the code to the github.

Highlight 1 file changed, 26 insertions(+)

Highlight create mode 100644 .github/workflows/main.yml

The output shows that our file main dot yml was fetched.
Only narration. Now we will enable the API in our code that is disabled.
Open the file app.js in the text editor. Open the file app dot js in the text editor.
Highlight app.get('/quote', async (req, res) => {

res.send(getRandomQuote());

})

We will uncomment this code to enable the API
Save the file by pressing Ctrl and S keys simultaneously. Save the file by pressing Ctrl and S keys simultaneously.
Only narration. Now we will push the code to GitHub.

Then, an image will be automatically built by GitHub Actions.

Switch to the terminal window. Switch to the terminal window.

Make sure that you are in the node-express directory .

Type git add . and press Enter. Type git space add space dot and press Enter.
Type git commit -m "Enabled API" and press Enter. To commit the changes, type the command as shown.

Press Enter

Type git push origin main and press Enter. Type git space push space origin space main and press Enter.
Highlight main -> main in the command output. Now our code is pushed to GitHub.
Switch to the browser tab where GitHub is open. Switch to the browser tab where GitHub is open.
Highlight Enabled API under Actions tab. You will see a job workflow run named Enabled API, shown by the yellow circle.
Highlight green tick mark on the left of Enabled API. The build is completed, which is denoted by the green tick mark
Only narration Now we will pull the latest image on Docker Hub with the changes we did.
Switch to the terminal window. Switch to the terminal window.
Type sudo docker pull [docker hub username]/node-express:latest

Highlight [docker hub username]

Press Enter.

Type the code as shown.

Make sure to type your own Docker Hub username.

Press Enter.

Enter password for root account and press Enter. Enter password if prompted and press Enter.
Wait for the download to complete. Wait for the download to complete.

It can take some time depending on your internet speed.

Only narration. Let us now run this image.
Type sudo docker run -d -p 127.0.0.1:3000:3000 [docker hub username]/node-express:latest.

Highlight [docker hub username]

Press Enter.

Type the command as shown.

Make sure to type your own Docker Hub username

Press Enter.

Open a new browser tab.

Type the address http://localhost:3000/quote

Press Enter.

Now open a new browser tab and type the address shown.

This is the endpoint of the Quotes API that we just enabled.

Press Enter.

Highlight the text on the screen. A random quote is displayed.

This confirms that the image was successfully updated in Docker Hub.

Show Slide:

Summary

This brings us to the end of this tutorial. Let us summarise.

In this tutorial, we have learnt how to

  • Setup and configure GitHub
  • Automate Docker builds using GitHub
  • Pull and test the built images
Show Slide: About Spoken Tutorial project The video at the following link summarizes the Spoken Tutorial project.

Please download and watch it

Show Slide:

Spoken Tutorial Workshops

The Spoken Tutorial Project team conducts workshops and gives certificates.

For more details, please write to us.

Show Slide:

Answers for THIS Spoken Tutorial

Please post your timed queries in this forum.
Show Slide:

FOSSEE Forum

For any general or technical questions on Docker, visit the FOSSEE forum and post your question.
Slide:

Acknowledgement

Spoken Tutorial Project was established by the Ministry of Education, Government of India
Show slide:

Thank You

This is Karthik Chandrasekhar, a FOSSEE Semester Long intern 2024, IIT Bombay, signing off.

Thanks for joining.

Contributors and Content Editors

Madhurig, Nirmala Venkat