A TypeScript library for working with Docker Compose configurations, providing strong typing and easy manipulation of Docker Compose data structures.
this lib is behind composecraft.com
compose-craft-lib
is a powerful TypeScript library designed to simplify working with Docker Compose configurations. It offers:
Install the library using npm:
npm install @composecraft/docker-compose-lib
Or using yarn:
yarn add @composecraft/docker-compose-lib
Or using pnpm:
pnpm add @composecraft/docker-compose-lib
import { Compose, Service, Image, PortMapping, Translator } from "@composecraft/docker-compose-lib"
import { stringify } from "yaml";
// Create a new Compose configuration
const compose = new Compose({name: "demo"});
// Define a web service
const webService = new Service({
name: "web",
image: new Image({ name: "nginx" }),
ports: [new PortMapping({ hostPort: 80, containerPort: 80 })],
});
// Add the service to the composition
compose.addService(webService);
// Translate to a dictionary and convert to YAML
const translator = new Translator(compose);
const yamlConfig = stringify(translator.toDict());
For detailed API documentation, please visit the official documentation.
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENSE
for more information.
Project Link: https://github.com/composecraft/docker-compose-lib