Build build

Builds containers or applications that can be used in blueprints. The build stanza runs a docker build using the dockerfile or context defined in the container stanza. You can use this feature to build container images that can be started directly using the container resource, or copied to nomad or kubernetes.

In addition to building containers, build blocks can be used to build application code in a docker container, the product of which can be copied to the local file system using the optional output stanza.

Properties

  • Name
    container
    Type
    (container: {})
    Required
    Readonly
    Description

    Build a container from the given file and context. Images are cached in the local Docker engine using the following convention.

  • Name
    output
    Type
    (output: {})
    Required
    Readonly
    Description

    Copy artifacts from the built container image to the local filesystem.

  • Name
    registry
    Type
    (registry: {})
    Required
    Readonly
    Description

    Registry credentials for pushing images to a remote registry.

  • Name
    image
    Type
    (string: "")
    Required
    Readonly
    readonly
    Description

    The built image reference that can be used by other resources.

  • Name
    build_checksum
    Type
    (string: "")
    Required
    Readonly
    readonly
    Description

    A checksum of the build context used to determine if the image needs to be rebuilt.


container

container {
  dockerfile = "Dockerfile"
  context    = "./src"
}
  • Name
    dockerfile
    Type
    (string: Dockerfile)
    Required
    Readonly
    Description

    Docker file to use for the build.

  • Name
    context
    Type
    (string: "")
    Required
    required
    Readonly
    Description

    Path to the context for the build.

  • Name
    tag
    Type
    (string: "")
    Required
    Readonly
    Description

    Tag to tag the resulting image with.

  • Name
    args
    Type
    (map[string]string: map[]{})
    Required
    Readonly
    Description

    Build args to pass to the build.

  • Name
    ignore
    Type
    ([]string: [])
    Required
    Readonly
    Description

    Patterns to ignore when calculating the build context checksum (similar to .dockerignore format).


output

output {
  source = "/bin/myapp"
  destination = "${data("local_app")}/bin"
}
  • Name
    source
    Type
    (string: "")
    Required
    Readonly
    Description

    The source directory or file to be copied from the built container

  • Name
    destination
    Type
    (string: "")
    Required
    Readonly
    Description

    The location to copy the files or directory to


registry

Registry credentials for pushing images to a remote registry.

registry {
  name     = "docker.io/myuser/myimage"
  username = "myuser"
  password = "mypassword"
}
  • Name
    name
    Type
    (string: "")
    Required
    Readonly
    Description

    The full image name including registry (e.g., docker.io/myuser/myimage).

  • Name
    username
    Type
    (string: "")
    Required
    Readonly
    Description

    Username for registry authentication.

  • Name
    password
    Type
    (string: "")
    Required
    Readonly
    Description

    Password for registry authentication.

Meta Properties

In addition to the main properties, all resources have meta properties, such as the id of the resource. To see the list of these properties please see the Meta Properties section in the documentation /docs/resources/meta.

Examples

Container build

resource "build" "app" {
  container {
    dockerfile = "Dockerfile"
    context    = "./src"
  }
}

resource "container" "app" {
  image {
    name = resource.build.app.image
  }

  command = ["/bin/app"]

  port {
    local  = 9090
    remote = 9090
    host   = 9090
  }

  network {
    id = resource.network.onprem.meta.id
  }
}

Application build

resource "build" "app" {
  container {
    dockerfile = "Dockerfile"
    context    = "./src"
  }

  output {
    source = "/go/src/github.com/jumppad-labs/jumppad/bin"
    destination = "${data("local_app")}/bin"
  }
}

resource "exec" "app" {
  script = <<-EOF
    jumppad up ./config
  EOF
}