Skip to navigation

Build an image from a Dockerfile

Builds an image on each sandbox vendor from Dockerfile text, so that sandboxes can start from it with image_id. The call returns at once. Each vendor’s build has its own status in builds. Poll GET /v1/images/{image_id}, or pass ?wait=true to hold the request until every build is ready or failed.

The same Dockerfile text and build context always give the same image id within a project. Calling this again for an image that exists returns it with 200 and builds nothing, so a caller that starts the same environment many times builds once. name is a label and is not part of the identity.

If the Dockerfile copies local files (COPY, ADD), upload them first with POST /v1/build-contexts and pass the returned id as build_context_id.

Rules:

  • dockerfile is required and at most 512 KiB.
  • build_on picks the vendors to build on now. Left out, Meadow builds on every vendor in the project’s sandbox order that the account has a key for. A vendor that is not built here builds on first use by a sandbox, which counts toward that sandbox’s create timeout.
  • On a project with routing.lock, sending build_on returns 403.
  • rebuild: true builds again and keeps the same id. The previous build’s vendor image is removed, unless a sandbox created from this image is still creating, running, or terminating.
  • Daytona does not support registry_auth. A build that sends it fails on Daytona.
  • A sandbox from image_id gets the size it asks for on both vendors. Daytona fixes resources on a snapshot, so Meadow keeps one Daytona snapshot per image and size, and the first sandbox of a new size waits for that snapshot to be made. See image_id on POST /v1/sandboxes.
  • Unknown fields return 400.

Scope: sandboxes.

curl -sS -X POST "$MEADOW_BASE_URL/v1/images?wait=true" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"tools-example","dockerfile":"FROM python:3.12-slim\nRUN pip install --no-cache-dir httpx==0.27.2\n"}'

Authentication

AuthorizationBearer

A Meadow API key, sent as Authorization: Bearer mdw_.... The header x-api-key: mdw_... is accepted in its place.

Headers

Idempotency-KeystringOptionalformat: "^[ -~]+$"1-255 characters

Makes a retry safe. A repeat with the same key and the same body returns the result of the first call instead of starting again. The same key with a different body returns 409. On POST /v1/keys, POST /v1/projects and POST /v1/images a value is scoped to the API key that sent it: another key that sends the same value starts its own request. The sandbox and exec routes scope it to the API key too. On the exec route the header only has an effect with background: true. See Idempotency in the introduction for how long a value is kept.

The key is 1 to 255 bytes of printable ASCII. A blank, longer, or non-ASCII key, or the header sent twice, returns 400. A UUID works well.

Query parameters

waitbooleanOptionalDefaults to false

When true, hold the request until every build started by this call is ready or failed, or until wait_timeout_seconds passes.

wait_timeout_secondsintegerOptional<=1800Defaults to 600

Longest time to hold the request when wait is true, in seconds, from 1 to 1800. A value outside that range returns 400. The builds continue after the wait ends.

Request

At most 1 MiB.
dockerfilestringRequired
The Dockerfile text, at most 512 KiB. Not a path.
namestringOptional
A label for people. Not part of the image identity. Must not be empty when sent.
build_context_idstringOptional

Local files for the build, from POST /v1/build-contexts. Without it, COPY of local files fails.

registry_authobjectOptional
Login for a private base image. Both fields are required when it is sent. Not supported on Daytona.
rebuildbooleanOptionalDefaults to false

Build again even when an image with these inputs exists. The id stays the same. The previous build’s vendor image is removed, unless a sandbox created with this image_id is still live.

build_onlist of enumsOptional
Providers to build on now. Default is every provider in the project's sandbox order that the account has a key for. Returns 403 on a locked project.
Allowed values:

Response headers

x-request-idstringOptional

Meadow’s id for this request, req_ and 24 hex characters. Every response carries it, including errors, streams and unknown routes. Every error in the Error schema repeats it as request_id. Quote it when you report a problem.

Idempotent-ReplayedenumOptional

true when this response is the saved result of an earlier request with the same Idempotency-Key. Absent on a first response. Sent by POST /v1/keys, POST /v1/projects, POST /v1/images, POST /v1/sandboxes and a background POST /v1/sandboxes/{sandbox_id}/exec. On the two sandbox routes the body is the sandbox or the command as it is now.

Allowed values:

Response

An image with this Dockerfile and build context already exists. Nothing was built.
idstring

Pass as image_id on POST /v1/sandboxes.

buildslist of objects
One entry per provider the image has been built on, or is building on.
created_atdatetime
When the image was first created.
project_idstringOptional
The project the image belongs to.
statusenumOptional
  • active: the image can be used.
  • deleting: DELETE /v1/images/{image_id} was called and a vendor image is still being removed. A deleting image cannot start a sandbox. Posting the same Dockerfile again builds a new image with a new id.
  • deleted: shown only on an image with vendor_copies_may_remain, which stays readable. Any other deleted image returns 404.
Allowed values:
vendor_copies_may_remainlist of enumsOptional

Vendors where Meadow stopped trying to delete its copy of this image, so a copy may still exist there. Absent when there are none. See DELETE /v1/images/{image_id}. An active image can carry it too: a rebuild removes the previous build’s vendor image under the same rule. Deleting such an image later returns 200, not 204, and it stays readable as deleted.

Allowed values:
namestring or nullOptional
The label given at create. Null when none was given.
sha256stringOptional
Hash of the Dockerfile text and build context. Two images with the same hash in one project are the same image.

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
409
Conflict Error
413
Content Too Large Error
422
Unprocessable Entity Error
429
Too Many Requests Error
500
Internal Server Error