Closed github-learning-lab[bot] closed 2 years ago
We are going to edit the current workflow file in our repository by adding a job that turns our Dockerfile
into a Docker Image
.
ci-workflow.yml
to cd-workflow.yml
:Node CI
to Docker CD
yaml name: Docker CD
Build-and-Push-Docker-Image:
runs-on: ubuntu-latest
needs: test
name: Docker Build, Tag, Push
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Download built artifact
uses: actions/download-artifact@main
with:
name: webpack artifacts
path: public
- name: Build container image
uses: docker/build-push-action@v1
with:
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
registry: docker.pkg.github.com
repository: BryanSchullerApini/github-actions-for-packages/tic-tac-toe
tag_with_sha: true
I have merged this pull request for you, and opened a new one for you to start working on the CD segment of our workflow.
Navigate to the next pull request to continue this course.
Docker 🐳
What is Docker?
Docker is an engine that allows you to run containers. Containers have many advantages, including:
Docker vs Virtual Machines
Dockerfiles, Images, and Container
Before moving forward with the workflow file, let's spend some time on these concepts. There are important differences between Dockerfiles, Images, and Containers.
What about our workflow?
Our repository contains a
Dockerfile
, source code, and tests for the Tic Tac Toe application.Our CI Workflow allows us to make code changes. Those changes will trigger an automated build and automated test. But, the automation does not create a deployable artifact.
We will place our application into a Docker container. Then, we will have a deployable package. A deployable package enables CD.
Because a
Dockerfile
is a text file, we are able to version it as source code. This configuration as code allowing us a single point of truth for our application.As you learned above, we need to turn that Dockerfile into a Docker image if we want to create a runtime instance. We are going to store that image in GitHub Packages.
📖Read More about Docker.