Giter Club home page Giter Club logo

nuke-docker-github-registry's Introduction

NUKE + Docker Image + GitHub Image Registry = โ™ฅ

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 Image registry.

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

About

โ„น The sample API used in this repo is a .NET 7 WebAPI project utilizing the newly introduced built-in container support. I've also included a dockerfile which is also utilized in the CI pipeline. 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 images. 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 artifacts produced by the GitHub Actions CI pipeline are two images with different tags. One of the images is built with the traditional Dockerfile, while the other one utilizes the newly introduced built-in container support via the Microsoft.NET.Build.Containers NuGet package.

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

Local Setup


Built-in container support

To build the docker image with the built-in container support, execute the following NUKE target:

# Global tool
nuke BuildApiImageWithBuiltInContainerSupport

# Shell script:
./build.sh BuildApiImageWithBuiltInContainerSupport

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

โ— Only Linux-x64 containers are supported with this approach.

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 dockerfile tag: magic-8-ball-api:dockerfile.

Run the containers

You can write a custom docker-compose.yml file or just run it:

# Image built with built-in container support
docker run -d -p 5000:80 --name m8b magic-8-ball-api:built-in

# Image built with dockerfile
docker run -d -p 5000:80 --name m8b magic-8-ball-api:dockerfile

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:dockerfile
docker rmi magic-8-ball-api:built-in 

nuke-docker-github-registry's People

Contributors

dependabot[bot] avatar sonnyrr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nuke-docker-github-registry's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.