Skip to content

TypeScript Docker Compose runtime

License

Notifications You must be signed in to change notification settings

evilkiwi/compose

Repository files navigation

NPM Discord GPL-3.0-only

Docker Compose TypeScript Runtime

@evilkiwi/compose provides TypeScript bindings to Docker Compose commands and syntax.

  • Supports both Compose v1 & v2
  • Functional API
  • Side-effect free
  • Zero dependencies
  • ES Module
  • Less than 3kb

Installation

This package is available via NPM:

yarn add @evilkiwi/compose

# or

npm install @evilkiwi/compose

Usage

import { compose } from '@evilkiwi/compose';

// By default, the current cwd will be used.
await compose().up();

// You can specify a different cwd, too.
await compose({ cwd: '/path/to/project' }).up();

// As well as cwd, the files used for docker compose can be specified.
await compose({
  cwd: '/path/to/project',
  path: ['my-compose-file.yaml'],
}).up();

// Or you can alternatively specify your compose config inline as a string.
await compose({
  cwd: '/path/to/project',
  config: `
name: my-project

services:
  proxy:
    container_name: proxy
    image: nginx:latest
    restart: always`,
}).up();

// `@evilkiwi/compose` uses Docker Compose v2 by default, you can force it to use v1.
await compose({
  cwd: '/path/to/project',
  v1: true,
}).up();