Answered step by step
Verified Expert Solution
Link Copied!

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:
1. Set up your working space:
Create a new repository on GitHub as "assignment6".
Initialize the repository with a README.
2. 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.
3. 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 build-container.yml.
Replace the content of the workflow file with the following:
name: Build and Push Container
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Login to Docker registry
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push container
run: |
docker build -t my-container .
docker tag my-container /:
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
4. 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: DOCKER_USERNAME and DOCKER_PASSWORD.
Set the values of these secrets to your Docker HUB username and password, respectively.
5. Commit and push changes:
Add, Commit, and Push the changes to your repository.
6. 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.
7. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions