Class Build

  • All Implemented Interfaces:
    com.oracle.bedrock.runtime.MetaClass<com.oracle.bedrock.runtime.Application>

    public class Build
    extends AbstractDockerCommand<Build>
    A representation of the Docker build command.

    Instances of Build are immutable, methods that add options and configuration to this Build command return a new instance of a Build command with the modifications applied.

    Copyright (c) 2016. All Rights Reserved. Oracle Corporation.
    Oracle is a registered trademark of Oracle Corporation and/or its affiliates.

    Author:
    Jonathan Knight
    • Field Detail

      • DEFAULT_TIMEOUT

        public static final com.oracle.bedrock.options.Timeout DEFAULT_TIMEOUT
        The default timeout for build commands.
    • Method Detail

      • withCommandArguments

        public Build withCommandArguments​(com.oracle.bedrock.runtime.options.Argument... args)
        Description copied from class: AbstractDockerCommand
        Obtain a copy of this AbstractDockerCommand with the addition of the specified command arguments Arguments.

        Command arguments in Docker come after the command name on the command line, e.g. docker [options...] COMMAND_NAME [args...] Parts of the Docker documentation that refer to these parameters as both arguments and options. In our case we refer to them as arguments and the are applied after the command name on the command line.

        Specified by:
        withCommandArguments in class AbstractDockerCommand<Build>
        Parameters:
        args - the additional Arguments
        Returns:
        a copy of this AbstractDockerCommand with the addition of the specified Arguments
      • withoutCommandArguments

        public Build withoutCommandArguments​(com.oracle.bedrock.runtime.options.Argument... args)
        Description copied from class: AbstractDockerCommand
        Obtain a copy of this AbstractDockerCommand without the specified command arguments Arguments.

        Command arguments in Docker come after the command name on the command line, e.g. docker [options...] COMMAND_NAME [args...] Parts of the Docker documentation that refer to these parameters as both arguments and options. In our case we refer to them as arguments and the are applied after the command name on the command line.

        Specified by:
        withoutCommandArguments in class AbstractDockerCommand<Build>
        Parameters:
        args - the additional Arguments
        Returns:
        a copy of this AbstractDockerCommand without the specified Arguments
      • withTags

        public Build withTags​(Object... tags)
        Obtain a Build command that is the same as this command with the specified --tag build argument values. The value equates to one or more name and optionally a tag in the 'name:tag' format
        Parameters:
        tags - the values to use for the --tag argument
        Returns:
        a Build command that is the same as this command with the specified --tag argument values
      • buildContextAt

        public Build buildContextAt​(File location)
        Obtain a Build command that is a copy of this Build command with the specified build context location.
        Parameters:
        location - the location of the build context
        Returns:
        a Build command that is a copy of this Build command with the specified build context location
      • buildContextAt

        public Build buildContextAt​(URL location)
        Obtain a Build command that is a copy of this Build command with the specified build context location.
        Parameters:
        location - the location of the build context
        Returns:
        a Build command that is a copy of this Build command with the specified build context location
      • buildArgs

        public Build buildArgs​(Object... args)
        Obtain a Build command that is a copy of this Build command with the specified --build-args option.
        Parameters:
        args - one or more values that resolve to build time arguments
        Returns:
        a Build command that is a copy of this Build command with the specified --build-args option
      • cpuShares

        public Build cpuShares()
        Obtain a Build command that is a copy of this Build command with the specified --cpu-shares=true option.
        Returns:
        a Build command that is a copy of this Build command with the specified --cpu-shares=true option
      • cpuShares

        public Build cpuShares​(boolean enabled)
        Obtain a Build command that is a copy of this Build command with the specified --cpu-shares option.
        Parameters:
        enabled - whether to enable ot disable cpu-shares
        Returns:
        a Build command that is a copy of this Build command with the specified --cpu-shares option
      • cgroupParent

        public Build cgroupParent​(String parent)
        Create a new Build command that is a copy of this Build command with the --cgroup-parent option applied.
        Parameters:
        parent - the parent cgroup for the container
        Returns:
        a new Build command that is a copy of this Build command with the --cgroup-parent option applied.
      • cpuPeriod

        public Build cpuPeriod​(int value)
        Create a new Build command that is a copy of this Build command with the --cpu-period option applied.
        Parameters:
        value - Limit CPU CFS (Completely Fair Scheduler) period
        Returns:
        a new Build command that is a copy of this Build command with the --cpu-period option applied.
      • cpuQuota

        public Build cpuQuota​(int value)
        Create a new Build command that is a copy of this Build command with the --cpu-quota option applied.
        Parameters:
        value - Limit CPU CFS (Completely Fair Scheduler) quota
        Returns:
        a new Build command that is a copy of this Build command with the --cpu-quota option applied.
      • cpuSetCPUs

        public Build cpuSetCPUs​(String value)
        Create a new Build command that is a copy of this Build command with the --cpuset-cpus option applied.
        Parameters:
        value - the CPUs in which to allow execution (0-3, 0,1, etc)
        Returns:
        a new Build command that is a copy of this Build command with the --cpuset-cpus option applied.
      • cpuSetMems

        public Build cpuSetMems​(String value)
        Create a new Build command that is a copy of this Build command with the --cpuset-mems option applied.
        Parameters:
        value - the memory nodes (MEMs) in which to allow execution (0-3, 0,1, etc)
        Returns:
        a new Build command that is a copy of this Build command with the --cpuset-mems option applied.
      • disableContentTrust

        public Build disableContentTrust()
        Create a new Build command that is a copy of this Build command with the --disable-content-trust option applied.
        Returns:
        a new Build command that is a copy of this Build command with the --disable-content-trust option applied.
      • enableContentTrust

        public Build enableContentTrust()
        Create a new Build command that is a copy of this Build command with the --disable-content-trust option applied.
        Returns:
        a new Build command that is a copy of this Build command with the --disable-content-trust option applied.
      • dockerFileName

        public Build dockerFileName​(String name)
        Create a new Build command that is a copy of this Build command with the --file option applied.
        Parameters:
        name - the name of the Dockerfile to use for the build
        Returns:
        a new Build command that is a copy of this Build command with the --file option applied.
      • forceRM

        public Build forceRM()
        Create a new Build command that is a copy of this Build command with the --force-rm option applied.
        Returns:
        a new Build command that is a copy of this Build command with the --force-rm option applied.
      • forceRM

        public Build forceRM​(boolean force)
        Create a new Build command that is a copy of this Build command with the --force-rm option applied.
        Parameters:
        force - true to alway remove intermediate containers
        Returns:
        a new Build command that is a copy of this Build command with the --force-rm option applied.
      • isolation

        public Build isolation​(String value)
        Create a new Build command that is a copy of this Build command with the --isolation option applied.
        Parameters:
        value - the container isolation technology to use
        Returns:
        a new Build command that is a copy of this Build command with the --isolation option applied.
      • labels

        public Build labels​(Object... values)
        Create a new Build command that is a copy of this Build command with the --label option applied.
        Parameters:
        values - one or more values resolving to labels to assign to the image
        Returns:
        a new Build command that is a copy of this Build command with the --label option applied.
      • memory

        public Build memory​(String limit)
        Create a new Build command that is a copy of this Build command with the --memory option applied.
        Parameters:
        limit - the memory limit to apply to the container
        Returns:
        a new Build command that is a copy of this Build command with the --memory option applied.
      • memorySwap

        public Build memorySwap​(String swap)
        Create a new Build command that is a copy of this Build command with the --memory-swap option applied.
        Parameters:
        swap - a positive integer equal to memory plus swap
        Returns:
        a new Build command that is a copy of this Build command with the --memory-swap option applied.
      • noCache

        public Build noCache()
        Create a new Build command that is a copy of this Build command with the --no-cache option applied.
        Returns:
        a new Build command that is a copy of this Build command with the --no-cache option applied.
      • noCache

        public Build noCache​(boolean noCache)
        Create a new Build command that is a copy of this Build command with the --no-cache option applied.
        Parameters:
        noCache - true to not use cache when building the image
        Returns:
        a new Build command that is a copy of this Build command with the --no-cache option applied.
      • alwaysPull

        public Build alwaysPull()
        Create a new Build command that is a copy of this Build command with the --pull option applied.
        Returns:
        a new Build command that is a copy of this Build command with the --pull option applied.
      • quiet

        public Build quiet()
        Create a new Build command that is a copy of this Build command with the --quiet option applied.
        Returns:
        a new Build command that is a copy of this Build command with the --quiet option applied.
      • quiet

        public Build quiet​(boolean quiet)
        Create a new Build command that is a copy of this Build command with the --quiet option applied.
        Parameters:
        quiet - true to enable quiet mode
        Returns:
        a new Build command that is a copy of this Build command with the --quiet option applied.
      • removeIntermidiateContainers

        public Build removeIntermidiateContainers()
        Create a new Build command that is a copy of this Build command with the --rm option applied.
        Returns:
        a new Build command that is a copy of this Build command with the --rm option applied.
      • removeIntermidiateContainers

        public Build removeIntermidiateContainers​(boolean rm)
        Create a new Build command that is a copy of this Build command with the --rm option applied.
        Parameters:
        rm - true to remove intermediate containers after successful build
        Returns:
        a new Build command that is a copy of this Build command with the --rm option applied.
      • shmSize

        public Build shmSize​(Object... values)
        Create a new Build command that is a copy of this Build command with the --shm-size option applied.

        The format is `<number><unit>`. `number` must be greater than `0`. Unit is optional and can be `b` (bytes), `k` (kilobytes), `m` (megabytes), or `g` (gigabytes). If you omit the unit, the system uses bytes. If you omit the size entirely, the system uses `64m`.

        Parameters:
        values - one or more values resolving to sizes of of `/dev/shm`.
        Returns:
        a new Build command that is a copy of this Build command with the --shm-size option applied.
      • ulimit

        public Build ulimit​(Object... options)
        Create a new Build command that is a copy of this Build command with the --ulimit option applied.
        Parameters:
        options - the Ulimit options
        Returns:
        a new Build command that is a copy of this Build command with the --ulimit option applied.
      • onLaunch

        public void onLaunch​(com.oracle.bedrock.runtime.Platform platform,
                             com.oracle.bedrock.OptionsByType optionsByType)
        Specified by:
        onLaunch in interface com.oracle.bedrock.runtime.MetaClass<com.oracle.bedrock.runtime.Application>
        Overrides:
        onLaunch in class AbstractDockerCommand<Build>
      • onLaunched

        public void onLaunched​(com.oracle.bedrock.runtime.Platform platform,
                               com.oracle.bedrock.runtime.Application application,
                               com.oracle.bedrock.OptionsByType optionsByType)
        Specified by:
        onLaunched in interface com.oracle.bedrock.runtime.MetaClass<com.oracle.bedrock.runtime.Application>
        Overrides:
        onLaunched in class AbstractDockerCommand<Build>
      • fromDockerFile

        public static Build fromDockerFile()
        Create a Build command that will build an image using the Dockerfile with the default Dockerfile name located in the working directory that the command is launched in.
        Returns:
        a Build command
      • fromDockerFile

        public static Build fromDockerFile​(String dockerFileName)
        Create a Build command that will build an image using the Dockerfile with the specified name located in the working directory that the command is launched in.
        Parameters:
        dockerFileName - the docker file name
        Returns:
        a Build command