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

docker-build-info

v0.6.0

Published

Conventional metadata for your builds

Downloads

138

Readme

docker-build-info

A light weight tool to provide conventional metadata for your docker builds.

Someone may have written a better version of this tool but I couldn't find it.

System Dependencies

This was written for use in mac/linux systems and assumes you have git installed. I've tried to keep things OS-independent, but I have not tested or verified other systems.

Getting Started

The "out-of-the-box" info captured:

  • buildId: A unique id to represent the build.
  • buildTimestamp: When the build was created.
  • buildVersion: A version that can be more granular than your latest tag... perfect for applications publishing multiple internal test builds, release-clients, etc. Derived via git (git describe --tags) if not explicitly stated.
  • commitSha: Unique id of the latest commit. Derived via git if not explicitly stated
  • commitStatus: Commit status of repo at build time (clean or dirty), denoting whether or not there or uncommited changes. Derived via git if not explicitly stated.
  • commitTitle: Title of the latest commit, i.e. the first line of the message. Derived via git if not explicitly stated.

Since each codebase is different, all of these standard values can be easily customized to fit your project.

CLI

This CLI is engineered to provide quick and easy results

To generate the build info file in your project (build-info.json), navigate to the project root and run:

npx docker-build-info create

If you're curious, you can inspect the generated info file

npx docker-build-info inspect

Need to customize the info that's captured? Just override one (or all) of the values... or provide your own

npx docker-build-info create -p "buildVersion=v1.2.0--test-build-1" -p "isTestBuild=true"

And if you're running this as part of a docker image build, the CLI can give you some easy-to-use build arguments to add this info directly onto your docker image

docker build . $(npx docker-build-info docker-args)

You can even do everything at once

docker build . $(npx docker-build-info create -p "buildVersion=v1.2.0--test-build-1" -p "isTestBuild=true" --dockerArgs)

API

You can also use docker-build-info in your project at runtime as a convenient way to access the generated build info or create a custom build script in node.

Install via

npm install docker-build-info

Then you can use it to create a custom build script in javascript

const dockerBuildInfo = require('docker-build-info')
import { execSync } from 'child_process'

async function buildDockerImage (customBuildVersion) {
  const buildInfo = await dockerBuildInfo.create({
    defaults: {
      buildVersion: customBuildVersion
    }
  })

  execSync(`docker build . ${dockerBuildInfo.getDockerBuildArgs(buildInfo)}`)
}

You can also easily reference the created build info at runtime (assuming the file is accessible)

const dockerBuildInfo = require('docker-build-info')

const buildInfo = dockerBuildInfo.load()
console.log(`The current build version is: ${buildInfo?.buildVersion || 'unknown'}`)