addendum

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 5 Imported by: 0

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.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is the major.minor.patch version of addendum.
	// Used to build a semantic version.
	// Meant to be be overridden at build time.
	Version = "0.0.0"
	// Prerelease is the prelease of addendum e.g. "alpha".
	// Used to build a semantic version.
	// Meant to be overridden at build time.
	Prerelease = ""
)

Functions

func Semver

func Semver() string

Semver returns the semantic version of addendum as built from Version, Prerelease and debug build info.

func WithLogger

func WithLogger(ctx context.Context, logger Logger) context.Context

WithLogger returns a Context from the parent Context with the given Logger inside of it.

Types

type Logger

type Logger = logr.Logger

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

func LoggerFrom

func LoggerFrom(ctx context.Context) Logger

LoggerFrom returns a Logger embedded within the given Context or a no-op Logger if no such Logger exists.

func NewLogger

func NewLogger() Logger

NewLogger creates a new Logger.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL