Skip to content

Instantly share code, notes, and snippets.

@vbatts
Created March 7, 2019 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vbatts/ab9e0dcf7aa3a36591b8669f5a85de0b to your computer and use it in GitHub Desktop.
Save vbatts/ab9e0dcf7aa3a36591b8669f5a85de0b to your computer and use it in GitHub Desktop.
I want repo:tag@digest from every layer in non-colliding values!
ARG IMAGE=fedora
ARG IMAGE_TAG=29
FROM ${IMAGE}:${IMAGE_TAG}
LABEL com.hashbangbash.image=${IMAGE}:${IMAGE_TAG}@${DIGEST}
LABEL com.hashbangbash.image.repo=${IMAGE}
LABEL com.hashbangbash.image.tag=${IMAGE_TAG}
LABEL com.hashbangbash.image.digest=${DIGEST}
RUN dnf update -y --refresh && \
dnf install -y bip && \
dnf clean all
OUTPUT ?= $(USER)/bip
CTR ?= podman
IMAGE ?= fedora
TAG ?= 29
.PHONY: image
image: .digest
$(CTR) build \
--build-arg "IMAGE=$(IMAGE)" \
--build-arg "IMAGE_TAG=$(TAG)" \
--build-arg "DIGEST=$(shell cat .digest)" \
-t $(OUTPUT) \
.
pull:
$(CTR) pull $(IMAGE):$(TAG)
.digest: pull
$(CTR) images --digests --format "{{.Digest}}" $(IMAGE):$(TAG) | head -1 | tee $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment