Skip to content

Lock-Distill is a tool designed to create "minimal" lockfiles to be used when building OCI/Docker images, in the context of monorepos.

License

Notifications You must be signed in to change notification settings

Coder-Spirit/lock-distill

Repository files navigation

Lock-Distill

NPM version License npm downloads Known Vulnerabilities Security Score

Introduction

Lock-Distill is a tool designed to create "minimal" lockfiles to be used when building OCI/Docker images, in the context of monorepos.

When working on monorepo environments, it is typical to rely on tools such as "yarn workspaces". This has some advantages, but it also presents some problems.

A very insidious problem is that a unique and global lockfile is shared between all the workspaces inside the monorepo. This has the unfortunate consequence that this lockfile will change with much higher frequency than if we had one repository per workspace.

The higher changes frequency implies that Docker Builder (or any other OCI image builders) will have to discard the cached layers based on that file more often, therefore having to spend more time and energy recomputing previously done work.

Install instructions

# With NPM
npm install @coderspirit/lock-distill

# Or with Yarn:
yarn add @coderspirit/lock-distill

Usage

We have to pass at least two options:

  • The application package.json file path
  • The file path for the global lockfile
lock-distill -p ./apps/svc1/package.json -l ./yarn.lock -o ./apps/svc1/distilled.yarn.lock

Once you have a "distilled" lockfile, you can COPY or mount it while building the Docker/OCI image.

Options

  • -p, --package <path>: The application's package.json file path. Required.
  • -l, --lockfile <path>: The monorepo's global lockfile path. Required.
  • -o, --output <path>: The path where to write the distillation output. If not passed, then the result can be directly read from stdout.
  • -m, --mode <full|workspace>: It specifies how aggressive will be the distillation process.
    • If set to workspace, then it will generate a new lockfile containing references to the workspace's prod & dev dependencies.
    • If set to full, then it will generate a new lockfile only containing references to the workspace's prod dependencies. This is the default option.
  • -t, --type: This option is not useful yet, as only Yarn v1.x is supported for now, but hopefully we'll introduce support for Yarn >=2, PNPM and others.

About

Lock-Distill is a tool designed to create "minimal" lockfiles to be used when building OCI/Docker images, in the context of monorepos.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published