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.


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.


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

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 "local_exec" "app" {
  command = ["jumppad", "up", "./config"]
}