Skip to content

SonnyRR/nuke-docker-github-registry

Repository files navigation

NUKE + Docker Image + GitHub Container Registry = β™₯

ci workflow status

This is a simple project utilizing the NUKE automated build system and Docker that serves as an example of how to push Docker Images to the GitHub Container registry.

Check out NUKE: https://github.com/nuke-build/nuke

πŸ’­ About

β„Ή The sample API used in this repo is a .NET 10 WebAPI project built with a multi-stage Dockerfile. It's a magic 8-ball, that when prompted with a yes/no question will give you a random answer.

πŸ— NUKE Build Project

The automated build project contains the necessary targets to clean, restore, compile, build and publish the docker image. You can view the target definitions in the Build.cs file and use it as a reference for your projects. It also contains a setup for GitVersion which lets us use semantic versioning when we tag the git commits & docker images.

πŸ“¦ CI Pipeline

The artifact produced by the GitHub Actions CI pipeline is a single image built with a multi-stage Dockerfile using the Alpine base image. The image is tagged with latest and the semantic version (e.g., magic-8-ball-api-1.0.0).

You can view the whole pipeline config here: .github/workflows/ci.yml and use it as a reference for your projects.

πŸ›  Local Setup

🐳 Dockerfile

To build the docker image with the Dockerfile, execute the following NUKE target:

# Global tool
nuke BuildApiImageWithDockerfile

# Shell script:
./build.sh BuildApiImageWithDockerfile

The aforementioned target will create a new image with the latest tag: magic-8-ball-api:latest.

πŸƒβ€β™€οΈ Run the container

docker run -d -p 5000:8080 --name m8b magic-8-ball-api:latest

After that you can navigate to http://localhost:5000 and it will redirect you to the swagger documentation for the API.

❗ I've intentionally not setup HTTPS redirection & not exposed the 443 port since that would require mounting additional volumes to access the development certifiacte. However feel free to update the docker run statement or a docker-compose file to mount those volumes & assign the necessary environment variables. You would also need to update the Dockerfile & API .csproj file to expose the ports.

To stop the container run the following command:

docker stop m8b

# To delete the container
docker rm m8b

# To delete the image
docker rmi magic-8-ball-api:latest

About

πŸ—œ An example project using NUKE + Docker + GitHub Image Registry that shows how to publish Docker images via GitHub actions.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors