Cloud Course Blog

Containers and Github Actions.

Docker containers, building them, creating a CI pipeline with Github actions making sure that the app would work on pull/push requests, this article will be a continuation of the previous one, here I will go more in depth on how Github actions can work with containers and will try to explain step by step.

Docker File

First we need to make a docker file, in order to make the image, we can think of images like the base, we need the image in order to make a container, the container is run once the application starts it uses the image and also stores other data and the container stores everything. In the following picture I will explain how the image works:

Dockerfile

Github Actions with docker image.

Going back to last blog post, we want to make our project try to build an image and check if it fails or succeeds in making it. In my example each time there is a push or pull request to the main branch it will run the Github actions based off our dotnet.yml file in our /.github/workflows folder. In this exercise it was still the same:

GitHub actions with docker job

Github Secret

I wanted to write a more prominent space for this, because in my workflow I am using github username and password, well… github already sorts the token out automatically. It just knows it has to sort out a token, so it does it on the background, there was no need to go in and make a secret and add a value in my project.

OUTRO

I hope this has proven helpful to someone out there, I know it can be confusing, specially if you want to understand what each thing does while using docker images and containers, along with actions!

References

Docker tag, extended description

About the Github token

Github Docker build-push

Github, build-push-action

Github, login-action

What’s wrong with the docker: latest tag?