Skip to content

You are viewing documentation for Instruqt 2.0 Labs. For Tracks documentation, please visit docs.instruqt.com.

Build


Defined insandbox.hcl

The build resource builds a container image from a Dockerfile during provisioning and, optionally, pushes it to one or more registries. Other resources can then reference the built image, letting a lab ship custom images without a separate CI pipeline.

resource "build" "app" {
container {
context = "./src"
dockerfile = "./Dockerfile"
}
}
resource "build" "app" {
container {
context = "./src"
dockerfile = "./Dockerfile"
args = {
VERSION = "1.0.0"
}
ignore = ["node_modules", ".git"]
}
registry {
name = "registry.example.com/app:latest"
}
}

Fields

FieldTypeRequiredDescription
containerblock✓Container build configuration
outputblock—Files or directories to copy from the containerrepeatable
registryblock—Registry to push the built image torepeatable

Container

build→Container

Container build configuration

FieldTypeRequiredDescription
dockerfilestring—Location of Dockerfile inside build context, defaults to ./Dockerfile
contextstring✓Path to build context
ignorelist(string)—Files to ignore in the build context, same as .dockerignore
argsmap(string)—Build args to pass to the container

Output

build→Output

Files or directories to copy from the container

FieldTypeRequiredDescription
sourcestring✓Source file or directory in the container
destinationstring✓Destination for copied file or directory

Registry

build→Registry

Registry to push the built image to

FieldTypeRequiredDescription
namestring✓Full image name including registry and tag
usernamestring—Registry username for authentication
passwordstring—Registry password for authentication

Computed Attributes

These attributes are set by the system and are read-only.

AttributeTypeDescription
imagestringFull local reference of the built image
build_checksumstringChecksum calculated from the build context files
resource "build" "app" {
container {
context = "./app"
}
}
resource "container" "app" {
image {
name = resource.build.app.image
}
}
  1. Small contexts: Keep the build context minimal and use ignore to exclude files that don’t belong in the image.
  2. Explicit tags: Give pushed images explicit tags in registry.name rather than relying on latest.