Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The objective of this exercise is to understand the basics of using GitHub Actions to work with our Containerfile. You will learn how to set
The objective of this exercise is to understand the basics of using GitHub Actions to work with our Containerfile. You will learn how to set up a workflow in GitHub Actions to automatically build and push a container image to a container registry using the defined Containerfile.
Instructions:
Set up your working space:
Create a new repository on GitHub as "assignment
Initialize the repository with a README.
Define a Dockerfile:
Create this Dockerrfile with anything you want.
Specify the base image, package installations, environment variables, and any other configurations you want for your container.
Add instructions to copy application code or files into the container and define the entry point command or script.
Save the changes to the Containerfile.
Set up GitHub Actions:
In your GitHub repository, navigate to the "Actions" tab.
Click on "Set up a workflow yourself" to create a new workflow file.
Name the workflow file, as buildcontainer.yml
Replace the content of the workflow file with the following:
name: Build and Push Container
on:
push:
branches:
main
jobs:
build:
runson: ubuntulatest
steps:
name: Checkout repository
uses: actionscheckout@v
name: Login to Docker registry
uses: dockerloginaction@v
with:
username: $ secretsDOCKERUSERNAME
password: $ secretsDOCKERPASSWORD
name: Build and push container
run:
docker build t mycontainer
docker tag mycontainer :
docker push :
Click the Commit changes... button
A confirmation screen will appear; click the Commit Changes button again
Note: Replace and with your desired values
Define secrets:
In the GitHub repository, navigate to the settings tab
On the left side menu, click on "Secrets and Variables" "Actions".
Click on the "New repository secret"
Create two secrets: DOCKERUSERNAME and DOCKERPASSWORD.
Set the values of these secrets to your Docker HUB username and password, respectively.
Commit and push changes:
Add, Commit, and Push the changes to your repository.
Verify the workflow execution:
Navigate to the "Actions" tab in your GitHub repository.
Verify that the workflow is triggered when you push changes to the main branch.
Monitor the workflow execution and ensure that it completes successfully.
Verify the container image in the registry:
Access your container registry
Verify that the container image specified in the workflow file is built and pushed to the registry.
Be sure to fully document each step, document the entire process and document every terminal command in a seperate word document for review.
This is for a Apple mac computer.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started