Categorygithub.com/frantjc/dockerfile-addendum
modulepackage
1.0.1
Repository: https://github.com/frantjc/dockerfile-addendum.git
Documentation: pkg.go.dev

# README

dockerfile-ADDendum CI godoc goreportcard license

Small script to pair with the Dockerfile ADD directive to make an idempotent action regardless of if the <src> of the ADD is a local tar archive or a tar archive from a remote URL.

use case

A Dockerfile's ADD directive is a bit finicky. It allows files to be added to the image either from a local directory or a remote URL. This has value in that if the <src> of the ADD is an ARG, then the functionality of the ADD can be changed with build-time arguments.

For example, this allows developers to lazily get the latest version of the dependency from a tar archive at some remote URL while CI consistently supplies the same tar archive to the Dockerfile as a --build-arg.

However, if that <src> is expected to be either a local tar archive or a remote tar archive, the ADD directive is not idempotent; ADD unpacks local tar archives but not remote ones. As a result, subsequent Dockerfile directives would have to account for the difference to make the build successful.

This is where the ADDendum comes in:

usage

FROM scratch
COPY --from=ghcr.io/frantjc/dockerfile-addendum /addendum /usr/local/bin
ARG tgz=zip_3.0_x86_64.tgz
ADD ${tgz} /tmp
RUN addendum -ruo /usr/local/bin /tmp/$(basename ${tgz})

Now this Dockerfile can be built with --build-arg tgz=<src> where <src> is either a tar archive at a remote URL or a local tar archive.

# Packages

No description provided by the author
No description provided by the author

# Functions

LoggerFrom returns a Logger embedded within the given Context or a no-op Logger if no such Logger exists.
NewLogger creates a new Logger.
Semver returns the semantic version of addendum as built from Version, Prerelease and debug build info.
WithLogger returns a Context from the parent Context with the given Logger inside of it.

# Variables

Prerelease is the prelease of addendum e.g.
Version is the major.minor.patch version of addendum.

# Type aliases

Logger is an alias to logr.Logger in case the logging library is desired to be swapped out.