Skip to content

The Docker container building CMake module that should have already existed

License

Notifications You must be signed in to change notification settings

AronRubin/DockerCMakeModule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DockerCMakeModule

GitHub top language GitHub repo size GitHub stars GitHub forks

The CMake module for Docker that should have already existed. This code is still a work in progress as it is a little unclear whether it

Prerequisites

Before you begin, ensure you have a project with:

  • Docker
  • CMake >= 3.12

Installing Docker CMake Module

This is just a single file cmake module with functions. Typically one would put it in a project's /cmake/modules directory, add that directory to the search path, and then include it. Feel free to include the functions in what ever manner conforms to your project's needs. Some don't use the modules subdirectory and that is fine.

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")

# a bunch of CMake directives later

include(Docker)
# now we can add docker targets
add_docker_target(eampletarget IMAGE outputimagename PATH_CONTEXT dir_of_context TAG postfix_tag_name)

Using Docker CMake Module

add_docker_target

Creates a cmake target to build an image from a Dockerfile or other context.

add_docker_target(<target_name>
        [IMAGE <image_name>]
        [TAG <primary_tag>]
        [REPOSITORY <repository_prefix>]
        [NO_DEFAULT_IMAGE_NAME]
        [PATH_CONTEXT <path> | URL_CONTEXT <url>]
        [DOCKERFILE <filename>]
        [BUILD_ARGS <arg0> [<arg2>]...]
        [OTHER_OPTIONS <option0> [<option1>]...]
        [TAGS <tag0> [<tag1>]...]
        )

This command creates a target for a docker build and adds all of the supplied information as properties on the target.

IMAGE

The name for the container image. This will result in the name passed to the -t tag argument argument on the docker build command line.

TAG

The tag postfix for the container image. The supplied string will be appended to the image name after a colon image:tag. This will result in the fully tagged name passed to the -t tag argument on the docker build command line.

Docker's documentation indicates the tag will default to latest if none is supplied.

REPOSITORY

The registry or repository scope for the container image. The supplied string will be prepended with a / to the image name as repository/image:tag. This will result in the name passed to the -t tag argument on the docker build command line.

NO_DEFAULT_IMAGE_NAME

Do not default the image name to the target name. If no image name is supplied, the docker build command line will have -t argument other than those from the TAGS property.

PATH_CONTEXT

Docker PATH context

URL_CONTEXT

Docker URL context

DOCKERFILE

Specify a dockerfile for the build. If none is supplied, when using a PATH context this function will reference a Dockerfile in that path if one exists.

filename

BUILD_ARGS []...]

Specify build-time variables.

Docker build args

OTHER_OPTIONS []...]

Not implemented in this version.

TAGS []...]

Specify additional tags to alias the built image to. The supplied tags are considered fully qualified and will be passed to the docker build commandline whole with -t tag

About

The Docker container building CMake module that should have already existed

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages