Search code examples
dockercakebuild

has anyone created a docker container using cake?


Has anyone been able to create a cake.build file that compiles a c# code then creates a docker container? I would like to be able to create a docker file once the base code is built and then run the docker image in a container.


Solution

  • You can build and run Docker images from your Cake scripts using the Cake.Docker community addin.

    Add #addin nuget:?package=Cake.Docker to the top of your build script and you can then use the DockerBuild alias to build your container. You can also optionally use DockerRun to run your container.

    You can find full documentation on this addin on the website, including for DockerBuild (and DockerRun).


    For example, assuming your Dockerfile in a folder called docker:

    #addin nuget:?package=Cake.Docker
    // the rest of your build script
    Task("Docker-Build")
    .Does(() => {
        var settings = new DockerImageBuildSettings { Tag = new[] {"dockerapp:latest" }};
        DockerBuild(settings, "./Docker");
    });