Job Type: Docker

March 14, 2022 ยท View on GitHub

The job type docker is one of the most important jobs. You can use it to run any Docker container you like.

{
    "version": 1,
    "jobs": [{
        "type": "docker",
        "name": "build",
        "docker_file": "infrabox/build-and-test/Dockerfile",
        "command": ["echo", "hello world"],
        "resources": { "limits": { "cpu": 1, "memory": 1024 } },
        "build_only": false,
        "enable_docker_build_kit": true,
        "build_context": "...",
        "cache": { ... },
        "timeout": 3600,
        "depends_on": ["other_job_name"],
        "environment": { ... },
        "build_arguments": { ... },
        "deployments": [ ... ],
        "security_context": { ... },
        "repository": { ... },
        "registries": [],
        "target": "specificstage"
    }]
}
NameRequiredTypeDefaultDescription
typetruestringHas to be "docker" to run a single Docker container
nametruestringName of the job
docker_filetruestringPath to the Dockerfile
commandfalsestringThe command in exec form to be used when the container is run. Ignored if build_only=true
resourcestrueResource ConfigurationSpecify the required resources for your job.
build_onlytruebooleantrueIf set to true the container will only be build but not run. Use it if you only want to build a container and push it to a registry. See here for how to push to a docker registry.
enable_docker_build_kitfalsebooleanfalseIf set to true, InfraBox will try to use the Dokcer Buildkit to build the containers. For more details, please refer to Docker docs
build_contextfalsestringSpecify the docker build context. If not set the directory containing the infrabox.json file will be used.
cachefalseCache Configuration{}Configure the caching behavior
timeoutfalseinteger3600Timeout in seconds after which the job should be killed. Timeout starts when the job is set to running
depends_onfalseDependency Configuration[]Jobs may have dependencies. You can list all jobs which should finish before the current job may be executed.
environmentfalseEnvironment Variables{}Can be used to set environment variables for the job.
build_argumentsfalseBuild Arguments{}Can be used to set docker build arguments.
deploymentsfalseDeployment Configuration[]Push your images to a registry.
security_contextfalseSecurity Context[]Configure security related options,
repositoryfalseRepository Configuration{}Configure git repository options.
registriesfalseSource Registry Configuration[]Configure the source registries.
targetfalsestringStop at a specific build stage when using a multi-stage Dockerfile. Reference.

Build Arguments

To set docker build arguments create an object with the names and values for build_arguments.

{
    "version": 1,
    "jobs": [{
        "type": "docker",
        ...
        "build_arguments": {
            "ARG_1": "My value",
            "ANOTHER_ARG": "some other value"
        }
    }]
}

Build arguments are only supported for docker job types.

Security Context

{
    "version": 1,
    "jobs": [{
        ...
        "security_context": {
            "privileged": false
        }
    }]
}
NameRequiredTypeDefaultDescription
privilegedfalsebooleanfalseIf set to true the container will be run in privileged mode