1.0.0-rc.4 • Published 2 years ago
@fadroma/oci v1.0.0-rc.4
@fadroma/oci
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 OCIConnection, OCIImage and OCIContainer abstractions, which
make it easy and performant to package and run reproducible operations
(such as containerized builds or ETL pipelines).
- The
OCIConnectionclass connects to the Docker runtime at/var/run/docker.sockor the path specified by theDOCKER_HOSTenvironment variable. - The
OCIImageclass 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
OCIImageinstance, you can launch one or moreOCIContainers. If you like, you can run multiple parallel operations in identical contexts (as specified by a single localDockerfile), and theImagewill build itself locally, only once and without touching Docker Hub.
Example
import { OCIConnection } from '@fadroma/oci'
const docker = new OCIConnection()
const image = docker.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
})Made with #%&! @ Hack.bg