npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-docker-compose

v0.0.11

Published

Docker Compose library and cli written for NodeJS

Downloads

25

Readme

Docker Compose API for NodeJS

Note - This is work under progress and at present compliance with any of the docker-compose schema version is not targeted

Motivation

Why node-docker-compose when there is a python version ?

The short answer is that I have a (private) project written using Typescript that needed to orchestrate docker containers. Initially I tried to invoke the docker-compose (python app) using child-process however the error handling and progress monitoring was not to my satisfaction (read -> it was a mess and I hated it !).

You may now suggest - Just use dockrode to do it. Your suggestion is valid to some extent, however my application still required a spec (an input file) for what needs to be created (i.e. images, volumes, networks) and run (i.e. containers). Therefore, instead of re-inventing yet another input specification I decided to re-use docker-compose.yaml syntax.

That said, at present I am only implementing the constructs/features that I need for my private project and will slowly add the support for other aspects of docker-compose to reach a level of compliance with few (if not all) docker-compose schema versions.

If you think the project has merits please feel free to contribute !

Installation

npm install node-docker-compose

Quick Start

import {Compose, Project} from 'node-docker-compose';

// Tip: use dotenv to read the environment variables
// and merge them in environmentVariables
const environmentVariables = { MY_ENV_VAR1 : 'value' };

// Create the project by passing the project config
const project = new Project({
    pull : true,    // Note - At present no impact
    composeSpec : composeFilePath,
    projectName : 'MyComposeProj',
    environmentVariables: environmentVariables
  });

const compose = new Compose(project);

// systematically first bring the down the project
// to remove any containers
await compose.down();

// bring up the project
await compose.up();

// if using private registry such as Google Container registry
// pass the AuthConfig
//
// in below example, it will be used for pulling images that start with 'gcr.io'
await compose.up([{
    username : 'oauth2accesstoken',
    password : gcrToken,
    serveraddress : 'gcr.io'
}]);

TODO

  • [ ] Support skipping creation of containers that already exist for the same project
  • [ ] Callbacks to inform the progress from higher level APIs (such as up and down)
  • [ ] Support to remove the networks
  • [ ] Config CLI command
  • [ ] Specify the list of environment files (only .env in project directory is supported for now)
  • [ ] If pull is false in ProjectConfig then do not fetch the latest image (if image is already present on the system)