Docker Rules

We provide a custom rule in cmake to allow you to build, tag, and deploy a simple Docker container:

    NAME <Container Target Name>
    FROM <Upstream Image Name>
    ENTRY_POINT <Target Name>
    DEPENDS <Target Names...>
    TAG <Local Tag Name>
    ACCOUNT <Account ID>
    FILES <Files...>
    PORTS <Ports...>
    PACKAGES <Packages...>
    ENV <Enviornment Variables...>
    ARK_CONFIG_PACKAGES <Config Packages...>
    ARK_VENVS <Virtual environment target names...>
    ECR_ID <Repository ID>)

If the container target name is not supplied, the script will use the entry point target name instead.

This will create a number of steps for, with the following names:

  • <Container Target Name>-container - Strips binaries and builds your Docker container
  • <Container Target Name>-deploy-push - Everything in container, plus the container is pushed
  • <Container Target Name>-docker - A shorthand for deploy-push

Many of these arguments are optional. For example, if “FROM” is not populated, the default will be ubuntu:latest. The only required arguments are:

  • TAG

Additionally, if ACCOUNT and ECR_ID are not specified, you do not gain the -deploy-push and -docker build targets (but you can still build a container with the -container target).

For example:

    ENTRY_POINT api_gateway
    TAG api_gateway
    DEPENDS catalog_scheduler catalog_sim
    FILES ark/myfile/1.txt ark/myfile/2.txt
    PORTS 8080
    PACKAGES wget curl
    ECR_ID api-gateway-ecr)

In the above example, this will copy api_gateway into the root of the container, and then copy each of the files into the root (preserving their full paths, so that api_gateway can access the files as ark/myfile1.txt (etc).

Additionally, catalog_scheduler and catalog_sim will be added into the container and dependency tree.

The “wget” and “curl” packages will be installed, and finally, the ports you list will be ’exposed’ in the Dockerfile.

This automatically generates a Dockerfile for you, based on your above commands. It currently assumes Ubuntu (Latest), and will install certificates and a few other bits you need for HTTPS to work.

Each configuration package specified will parse the YAML file provided to retrieve all dependencies of that file; these will all be added to your docker container.

Targets versus Scripts

If your entry point is a target, that target will be built automatically, stripped, and then added to the container. If it is not a target, it will simply be added to the container.

In the case of scripts, you must have your script in the same location as the CMakeLists.txt file that has the add_container directive within it.

Including Config Packages and VirtualEnvs

You can use the ARK_CONFIG_PACKAGES list to pass specific config package YAML files that you wish to have included in your container. Both the config package and all of its dependant files will be included.

Similarly, you can use the ARK_VENVS directive to copy in the virtual environments (using the Ark build system target name) into your container. Note that there is some coupling between the system Python and the virtualenv; it’s a good idea to keep your docker operating system image and host operating system image in sync.