2.0.8 • Published 4 months ago

@hackbg/dock v2.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@hackbg/dock

Want to run some operation from Node in a reproducible environment? Here's a really simple way to achieve that with containers.

Overview

This library builds upon Dockerode, and provides the Engine, Image and Container abstractions, which make it easy and performant to package and run reproducible operations (such as containerized builds or ETL pipelines).

  • The Engine class connects to the Docker runtime at /var/run/docker.sock or the path specified by the DOCKER_HOST environment variable.
  • The Image class supports specifying both an upstream tag to pull from Docker Hub, and/or a local fallback Dockerfile. This allows for fast iteration when constructing the Dockerized runtime environment.
  • From an Image instance, you can launch one or more Containers. If you like, you can run multiple parallel operations in identical contexts (as specified by a single local Dockerfile), and the Image will build itself locally, only once and without touching Docker Hub.

Example

import Docker from '@hackbg/dock'

const engine = new Docker.Engine()

const image = engine.image(
  'my-org/my-build-image:v1', // This image will be pulled
  '/path/to/my/Dockerfile',   // If the pull fails, build from this Dockerfile
  [] // Any local paths referenced from the Dockerfile should be added here
)

const container = await image.run(`build_${+new Date()}`, {
 readonly: { '/my/project/sources':   '/src'  }, // -v ro
 writable: { '/my/project/artifacts': '/dist' }, // -v rw
 mapped: { 80: 8080 } // container:host
})

Roadmap

  • Support Podman for fully rootless operation

Made with #%&! @ Hack.bg

2.0.8

4 months ago

2.0.7

5 months ago

2.0.5

6 months ago

2.0.6

5 months ago

1.4.1

1 year ago

1.3.2

1 year ago

1.4.0

1 year ago

2.0.1

12 months ago

2.0.0

12 months ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.0

1 year ago