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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bojanrajkovic/containerfile-ts

v2.0.0

Published

Type-safe Dockerfile/Containerfile generation with declarative TypeScript

Readme

containerfile-ts

CI npm version

Type-safe Dockerfile/Containerfile generation with declarative TypeScript, inspired by gha-ts.

Note: This is a vibe-coded library, built quickly with AI assistance as an experiment in declarative container definitions. It works, but take it in that spirit. PRs welcome if you find rough edges!

Installation

Stable release (npm):

npm install @bojanrajkovic/containerfile-ts
# or
pnpm add @bojanrajkovic/containerfile-ts
# or
yarn add @bojanrajkovic/containerfile-ts

Alpha releases (GitHub Packages):

To install pre-release versions from feature branches:

# Configure npm to use GitHub Package Registry for @bojanrajkovic scope
echo "@bojanrajkovic:registry=https://npm.pkg.github.com" >> .npmrc

# Install specific alpha version
pnpm add @bojanrajkovic/[email protected]

Note: GitHub Package Registry requires authentication. See GitHub Packages documentation for setup.

Usage

Simple Dockerfile

import {
  containerfile,
  from,
  workdir,
  copy,
  run,
  expose,
  cmd,
  render,
} from "@bojanrajkovic/containerfile-ts";

const dockerfile = containerfile({
  instructions: [
    from("node:20-alpine"),
    workdir("/app"),
    copy("package*.json", "."),
    run("npm ci"),
    copy(".", "."),
    expose(3000),
    cmd(["node", "dist/index.js"]),
  ],
});

console.log(render(dockerfile));

Output:

FROM node:20-alpine
WORKDIR /app
COPY package*.json .
RUN npm ci
COPY . .
EXPOSE 3000
CMD ["node", "dist/index.js"]

Multi-Stage Build

import {
  containerfile,
  stage,
  from,
  workdir,
  copy,
  run,
  cmd,
  render,
} from "@bojanrajkovic/containerfile-ts";

const dockerfile = containerfile({
  stages: [
    stage("builder", [
      from("node:20", { as: "builder" }),
      workdir("/app"),
      copy("package*.json", "."),
      run("npm ci"),
      copy(".", "."),
      run("npm run build"),
    ]),
    stage("runtime", [
      from("node:20-alpine", { as: "runtime" }),
      workdir("/app"),
      copy("/app/dist", "./dist", { from: "builder" }),
      cmd(["node", "dist/index.js"]),
    ]),
  ],
});

console.log(render(dockerfile));

API Reference

Factory Functions

| Function | Description | | --------------------------- | ------------------------------------- | | from(image, options?) | FROM instruction | | run(command) | RUN instruction (string or exec form) | | copy(src, dest, options?) | COPY instruction | | add(src, dest, options?) | ADD instruction | | workdir(path) | WORKDIR instruction | | env(key, value) | ENV instruction | | expose(port, options?) | EXPOSE instruction | | cmd(command) | CMD instruction (exec form) | | entrypoint(command) | ENTRYPOINT instruction (exec form) | | arg(name, options?) | ARG instruction | | label(key, value) | LABEL instruction | | stage(name, instructions) | Named stage for multi-stage builds | | containerfile(def) | Create containerfile definition |

Rendering

| Function | Description | | ----------------------- | --------------------------- | | render(containerfile) | Render to Dockerfile string |

Options

FromOptions

  • as?: string - Stage name (AS clause)
  • platform?: string - Target platform

CopyOptions

  • from?: string - Source stage name
  • chown?: string - Change ownership
  • chmod?: string - Change permissions

AddOptions

  • chown?: string - Change ownership
  • chmod?: string - Change permissions

ExposeOptions

  • protocol?: 'tcp' | 'udp' | 'sctp' - Port protocol (default: tcp)

ArgOptions

  • defaultValue?: string - Default value for build arg

Changelog

See CHANGELOG.md for release history and changes.

Note: The changelog is automatically generated from conventional commit messages.

License

MIT