Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove docker-compose (v1) #282

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ jobs:
runs-on: ubuntu-22.04
name: info
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
- run: docker-compose --version
- run: docker compose version
- run: node --version
lint:
runs-on: ubuntu-22.04
name: Lint
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
- run: yarn
Expand All @@ -33,11 +32,10 @@ jobs:
runs-on: ubuntu-22.04
name: Build + Test
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
- run: yarn
- run: yarn build
- run: yarn test-v1
- run: yarn test-v2
- run: yarn test
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"types": "dist/index.d.ts",
"scripts": {
"ci": "yarn install --frozen-lockfile",
"test-v1": "npx vitest --dir test/v1 --test-timeout=30000",
"test-v2": "npx vitest --dir test/v2 --test-timeout=30000",
"test": "npx vitest --dir test --test-timeout=30000",
"lint": "eslint src/**/*.ts test/**/*.ts",
"build": "tsc",
"prepublishOnly": "tsc",
Expand Down
26 changes: 5 additions & 21 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

`docker-compose` is a small library that allows you to run [docker-compose](https://docs.docker.com/compose/) (which is still required) via Node.js. This is useful to bootstrap test environments.

This library supports `docker-compose` (v1 standalone) and as of this version `docker compose` (v2, the docker "compose" plugin).
As of version 1.0, this library only supports `docker compose` (v2, the docker "compose" plugin). The `docker-compose` (v1) has been removed from recent releases of Docker Desktop and is no longer supported. Use the `0.x` versions of this library if you still need to use the old `docker-compose` (v1).

## Installation

Expand All @@ -21,9 +21,7 @@ The documentation can be found [here](https://pdmlab.github.io/docker-compose/).

## Example

### Import for `docker-compose` (v1)

To import commands for the v1 version, please use this import statement:
### Import for `docker-compose`

```ts
import * as compose from 'docker-compose'
Expand All @@ -35,20 +33,6 @@ You can also import only the required commands:
import { run, upAll } from 'docker-compose'
```

### Import for `docker compose` (v2)

To import commands for the v2 version, please use this import statement:

```ts
import { v2 as compose } from 'docker-compose'
```

You can also import only the required commands:

```ts
import { run, upAll } from 'docker-compose/dist/v2'
```

### Usage

To start service containers based on the `docker-compose.yml` file in your current directory, just call `compose.upAll` like this:
Expand Down Expand Up @@ -94,7 +78,7 @@ result.data.services.forEach((service) => {
})
```

The docker-compose v2 version also support the `--format json` command option to get a better state support:
The `--format json` command option can be used to get a better state support:

```javascript
const result = await compose.ps({ cwd: path.join(__dirname), commandOptions: [["--format", "json"]] })
Expand All @@ -104,9 +88,9 @@ result.data.services.forEach((service) => {
})
```

## Known issues with v2 support
## Known issues

* During testing we noticed that `docker compose` seems to send it's exit code also commands don't seem to have finished. This doesn't occur for all commands, but for example with `stop` or `down`. We had the option to wait for stopped / removed containers using third party libraries but this would make bootstrapping `docker-compose` much more complicated for the users. So we decided to use a `setTimeout(500)` workaround. We're aware this is not perfect but it seems to be the most appropriate solution for now. Details can be found in the [v2 PR discussion](https://github.com/PDMLab/docker-compose/pull/228#issuecomment-1422895821) (we're happy to get help here).
* During testing we noticed that `docker compose` seems to send its exit code also commands don't seem to have finished. This doesn't occur for all commands, but for example with `stop` or `down`. We had the option to wait for stopped / removed containers using third party libraries but this would make bootstrapping `docker-compose` much more complicated for the users. So we decided to use a `setTimeout(500)` workaround. We're aware this is not perfect, but it seems to be the most appropriate solution for now. Details can be found in the [v2 PR discussion](https://github.com/PDMLab/docker-compose/pull/228#issuecomment-1422895821) (we're happy to get help here).

## Running the tests

Expand Down
Loading
Loading