Skip to content

feat: add typed compose object support#325

Merged
AlexZeitler merged 2 commits intomasterfrom
feat/typed-compose-object
Mar 31, 2026
Merged

feat: add typed compose object support#325
AlexZeitler merged 2 commits intomasterfrom
feat/typed-compose-object

Conversation

@AlexZeitler
Copy link
Copy Markdown
Contributor

Summary

Closes #295

  • Adds a compose option to IDockerComposeOptions that accepts a typed ComposeSpecification object
  • TypeScript types are auto-generated from the official Compose Specification JSON Schema using json-schema-to-typescript
  • The object is serialized to YAML internally and piped via stdin using the existing configAsString path - no temporary files needed

Usage

import { upAll, ComposeSpecification } from 'docker-compose'

const compose: ComposeSpecification = {
  services: {
    web: { image: 'nginx:latest', ports: ['8080:80'] },
    db: { image: 'postgres:16' }
  }
}

await upAll({ compose })

Add a `compose` option to `IDockerComposeOptions` that accepts a
typed `ComposeSpecification` object. The object is serialized to YAML
internally and piped via stdin using the existing `configAsString` path.

TypeScript types are generated from the official Compose Specification
JSON Schema (Apache 2.0) using json-schema-to-typescript.
@AlexZeitler AlexZeitler force-pushed the feat/typed-compose-object branch from 0a979f3 to 83884bf Compare March 31, 2026 15:58
The .d.ts file has no runtime module, so use `export type` instead
of a value re-export to avoid ERR_MODULE_NOT_FOUND at runtime.
@AlexZeitler AlexZeitler merged commit 698d0f3 into master Mar 31, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript bindings to docker-compose schema

1 participant