Declarative image definitions for building sandboxes (and snapshots) from a Dockerfile instead of a prebuilt snapshot.
image =
ExDaytona.Image.from("ubuntu:22.04")
|> ExDaytona.Image.run("apt-get update && apt-get install -y curl git")
|> ExDaytona.Image.env(%{"LANG" => "C.UTF-8"})
|> ExDaytona.Image.workdir("/workspace")
{:ok, sandbox} = ExDaytona.Sandbox.create(client, image: image)
# Watch the build as it happens
ExDaytona.Sandbox.stream_build_logs(sandbox, &IO.write/1)A raw Dockerfile works too — ExDaytona.Sandbox.create/2 accepts
image: "FROM ubuntu:22.04\n..." directly, and raw/1 wraps one in an
%ExDaytona.Image{}.
Local files go in via add_local_file/3 and add_local_dir/3 — they
become COPY instructions backed by a build context that
ExDaytona.Sandbox.create/2 uploads to Daytona's object storage
automatically:
image =
ExDaytona.Image.from("elixir:1.20-alpine")
|> ExDaytona.Image.add_local_file("mix.exs", "/workspace/mix.exs")
|> ExDaytona.Image.add_local_dir("config", "/workspace/config")The rest of the DSL covers context-free instructions (RUN, ENV,
WORKDIR, USER, LABEL, EXPOSE, ENTRYPOINT, CMD) plus
instruction/2 as an escape hatch for anything else.
Summary
Functions
Copy a local directory (recursively) into the image at remote_path.
Uploaded as a build context when the sandbox is created.
Copy a local file into the image at remote_path (a trailing / keeps
the file's name). The file is uploaded as a build context when the
sandbox is created.
The ExDaytona.Model.CreateBuildInfo for this image — what
ExDaytona.Sandbox.create/2 sends when given image:, and what the
low-level snapshot API takes as buildInfo.
Set the CMD (exec form).
Render the definition to Dockerfile content.
Set the ENTRYPOINT (exec form).
Append ENV instructions from a map.
Append an EXPOSE instruction.
Start an image definition from a base image reference.
Append an arbitrary Dockerfile instruction line — the escape hatch for anything the DSL doesn't cover.
Append a LABEL instruction.
Wrap a complete raw Dockerfile.
Append a RUN instruction.
Append a USER instruction.
Append a WORKDIR instruction.
Types
Functions
Copy a local directory (recursively) into the image at remote_path.
Uploaded as a build context when the sandbox is created.
Copy a local file into the image at remote_path (a trailing / keeps
the file's name). The file is uploaded as a build context when the
sandbox is created.
Raises ArgumentError if the path does not exist or is not a regular
file — fail at definition time, not at build time.
@spec build_info(t() | String.t()) :: ExDaytona.Model.CreateBuildInfo.t()
The ExDaytona.Model.CreateBuildInfo for this image — what
ExDaytona.Sandbox.create/2 sends when given image:, and what the
low-level snapshot API takes as buildInfo.
Set the CMD (exec form).
Render the definition to Dockerfile content.
Set the ENTRYPOINT (exec form).
Append ENV instructions from a map.
@spec expose(t(), pos_integer()) :: t()
Append an EXPOSE instruction.
Start an image definition from a base image reference.
Append an arbitrary Dockerfile instruction line — the escape hatch for anything the DSL doesn't cover.
Append a LABEL instruction.
Wrap a complete raw Dockerfile.
Append a RUN instruction.
Append a USER instruction.
Append a WORKDIR instruction.