measuredockerbuild

0.0.3 • Public • Published

Measure Docker Build durations

Sometimes docker builds can take forever. That can be annoying especially when you have to rebuild the image mutliple times. But docker offers a great solution to minimize the build time -> CACHING.

To optimize your builds it can help that you know which steps need a lot of time. This simple cli measures the duration of each step and returns a nice table/json containing the data at the end.

It's as simple as

$ npx measuredockerbuild table <docker build args>
# e.g. npx measuredockerbuild table -t test . --no-cache
# 
# ...
#
# START BUILD                                        | 249 ms
# ------------------------------------------------------------------
# Step 1/5 : FROM docker:latest                      | 0 ms
# ------------------------------------------------------------------
# Step 2/5 : RUN apk add --no-cache nodejs npm       | 5608 ms
# ------------------------------------------------------------------
# Step 3/5 : RUN npm i -g measuredockerbuild         | 3859 ms
# ------------------------------------------------------------------
# Step 4/5 : ENTRYPOINT [ "measuredockerbuild" ]     | 96 ms
# ------------------------------------------------------------------
# Step 5/5 : CMD ["table", "."]                      | 108 ms
# ------------------------------------------------------------------
# END BUILD                                          | 9920 ms 

Installation

You can install it globally or locally or use npx. I recommend the global installation.

I test the cli on mac/linux

global installation

$ npm i -g measuredockerbuild

per project installation

$ npm i measuredockerbuild

no installation

$  npx measuredockerbuild ...

Usage

It's very simple, just choose the output format and then provide all arguments you would normally pass to docker build.

$ measuredockerbuild <json|table> <docker build args>

get all docker build arguments with

$ docker build --help

Usage without nodejs

You can use the tool, even when only docker is installed with the following image: milleniumfrog/measuredockerbuild:latest.

The image is a drop in replacement for the docker:latest but can use measuredockerbuild.

Mount /var/run/docker.sock, then you can build dockerimages inside a container.

$ docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/folder milleniumfrog/measuredockerbuild:latest measuredockerbuild table -t example  /folder

Additional

Readme

Keywords

Package Sidebar

Install

npm i measuredockerbuild

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

7.02 kB

Total Files

7

Last publish

Collaborators

  • milleniumfrog.de