パッケージの詳細

@dashevo/docker-compose

PDMLab228MIT0.24.4

Manage docker-compose from Node.js

devops, devops-tools, docker, docker-compose

readme

Conventional Commits Join the chat at https://gitter.im/pdmlab/docker-compose

Manage Docker-Compose via Node.js

docker-compose is a small library that allows you to run docker-compose(which is still required) via Node.js. This is useful to bootstrap test environments.

This package only works with Docker Compose v2 syntax.

Legacy docker-compose syntax is not supported in this repo.

Installation

yarn add --dev docker-compose

Documentation

The documentation can be found here.

Example

To start service containers based on the docker-compose.yml file in your current directory, just call compose.up like this:

compose.upAll({ cwd: path.join(__dirname), log: true }).then(
  () => {
    console.log('done')
  },
  (err) => {
    console.log('something went wrong:', err.message)
  }
)

To execute command inside a running container

compose.exec('node', 'npm install', { cwd: path.join(__dirname) })

Running the tests

While docker-compose runs on Node.js 6+, running the tests requires you to use Node.js 8+ as they make use of async/await.

yarn test

Want to help?

This project is just getting off the ground and could use some help with cleaning things up and refactoring.

If you want to contribute - we'd love it! Just open an issue to work against so you get full credit for your fork. You can open the issue first so we can discuss and you can work your fork as we go along.

If you see a bug, please be so kind as to show how it's failing, and we'll do our best to get it fixed quickly.

Before sending a PR, please create an issue to introduce your idea and have a reference for your PR.

We're using conventional commits, so please use it for your commits as well.

Also please add tests and make sure to run yarn lint.

Discussions

If you want to discuss an docker-compose issue or PR in more detail, feel free to start a discussion.

License

MIT License

Copyright (c) 2017 - 2021 PDMLab

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

更新履歴

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.24.1 (2022-06-28)

  • Moved out development dependencies to the dev section which reduced amount dependencies required when imported
  • Lowered typescript to 3.9.5 to match dashevo/platform monorepo
  • Bundled code before publishing to npm

0.24.0 (2022-06-09)

Switch to Docker Compose v2 syntax. This package is not compatible with docker-compose (v1) commands anymore

0.23.17 (2022-01-18)

Bug Fixes

0.23.16 (2022-01-16)

Features

0.23.15 (2022-01-14)

Bug Fixes

  • #178: fix quiet trim issue, add tests (#197) (2016bc7)

0.23.14 (2021-11-29)

Features

0.23.13 (2021-07-20)

Features

  • single container pause and unpause added (5921b51)

Bug Fixes

0.23.12 (2021-06-06)

Features

0.23.11 (2021-06-04)

0.23.10 (2021-05-11)

Bug Fixes

  • fix mapping ipv6-based port mappings (53fb971)
  • fix mapping ipv6-based port mappings (6dec0c6)
  • fix mapping ipv6-based port mappings (dbdb900)
  • fix mapping ipv6-based port mappings (8aa8465)
  • fix mapping ipv6-based port mappings (21b63cb)
  • fix mapping ipv6-based port mappings (48c9f08)
  • fix mapping ipv6-based port mappings (e7013df)

0.23.9 (2021-05-08)

Features

  • Add execPath option to set path to docker-compose executable (58f09f4)

0.23.8 (2021-04-15)

Bug Fixes

  • ignore vuepress cache + temp files on release (#148) (e58387d)

0.23.7 (2021-04-14)

Features

  • allow to pass docker compose configuration as string (e8c14d3)
  • make result for config --services command type safe (6f105ca)
  • make result for config --volumes command type safe (51b20b4)
  • make result for config command type safe (a2f5a4e)
  • make result for port command type safe (70a98f4)
  • make result for ps command type safe (880d252)
  • make result for version command type safe (a7da038)

Bug Fixes

  • filter empty entries from config --services command (ed91eba)
  • test: fix broken tests (afb2b11)

0.23.6 (2021-01-06)

Features

  • allow to pass docker compose configuration as string (e8c14d3)

0.23.5 (2020-07-10)

Bug Fixes

  • update flags incompatible with detached mode (c808fa2)

0.23.4 (2020-04-23)

Features

  • allow passing service names to rm function (3a68db7)

0.23.3 (2020-03-06)

Features

  • add ability to pass --abort-on-container-exit flag to up methods (e85af8c)

Bug Fixes

  • reset jest set timeout to original value (c4ed7ed)

0.23.2 (2019-12-31)

0.23.1 (2019-10-26)

0.23.0 / 2019-10-25

:tada: Enhancements

  • #97:
    • Add a version function

0.22.2 / 2019-08-31

:bug: Fixes

  • #94:
    • Fix a copy-paste typo for pull commands

0.22.1 / 2019-08-31

:tada: Enhancements

  • #93:
    • Add pull command methods to readme

:lock: Security Fixes

  • #92:
    • Fix eslint-utils security issue

0.22.0 / 2019-08-30

:tada: Enhancements

  • #90:
    • Add pullOne, pullMany and pullAll methods

0.21.0 / 2019-08-15

:tada: Enhancements

  • #89:
    • Add stopOne() command

0.20.2 / 2019-07-30

:tada: Enhancements

  • #87:
    • Use proper es2015 library (for Promises, etc.) in tsconfig

:bug: Fixes

  • #87:
    • Fix linting after build was called
  • #86:
    • Fix interfaces not being exposed in typings file

0.20.1 / 2019-07-26

:tada: Enhancements

  • #84:
    • Set Node 6.0 as minimum version

0.20.0 / 2019-07-23

:tada: Enhancements

  • #83:
    • Migrate to Typescript

0.19.0 / 2019-07-13

:tada: Enhancements

  • #77:
    • handle error based on exit code
    • replace tape with jest

0.18.0 / 2019-07-10

:tada: Enhancements

  • #82: Allow passing an array as command to run and exec

0.17.3 / 2019-05-29

:bug: Fixes

  • #69: Fix declaration for logs function

0.17.2 / 2019-05-02

:nut_and_bolt: Other

  • #69: Remove winston dependency and lib/log

0.17.1 / 2019-05-01

:bug: Fixes

  • #66: Trailing commas causing syntax error on NodeJS 6.x

0.17.0 / 2019-04-30

:tada: Enhancements

  • #58: Expose docker-compose exit code in results