Skip to content

Commit

Permalink
automatically derive image version
Browse files Browse the repository at this point in the history
  • Loading branch information
BenTheElder committed Jul 22, 2020
1 parent df7b541 commit 7d62be1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 0 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
# change is that the Hugo version is now an overridable argument rather than a fixed
# environment variable.

# Bump this by 1 whenever you change the Dockerfile below, e.g. if
# `DOCKERFFILE_VERSION=1` then change this to `DOCKERFILE_VERSION=2` when you
# change something else in this file.
# DOCKERFILE_VERSION=0

FROM alpine:latest

LABEL maintainer="Luc Perkins <[email protected]>"
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ NETLIFY_FUNC = $(NODE_BIN)/netlify-lambda
# but this can be overridden when calling make, e.g.
# CONTAINER_ENGINE=podman make container-image
CONTAINER_ENGINE ?= docker
DOCKERFILE_VERSION = $(shell grep DOCKERFILE_VERSION Dockerfile | tail -n 1 | cut -d '=' -f 2 | tr -d " \"\n")
CONTAINER_IMAGE = kubernetes-hugo:v$(HUGO_VERSION)-$(DOCKERFILE_VERSION)
IMAGE_VERSION=$(shell scripts/hash-files.sh Dockerfile Makefile | cut -c 1-12)
CONTAINER_IMAGE = kubernetes-hugo:v$(HUGO_VERSION)-$(IMAGE_VERSION)
CONTAINER_RUN = $(CONTAINER_ENGINE) run --rm --interactive --tty --volume $(CURDIR):/src

CCRED=\033[0;31m
Expand Down
10 changes: 10 additions & 0 deletions scripts/hash-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
# this script emits as hash for the files listed in $@
if command -v shasum >/dev/null 2>&1; then
cat "$@" | shasum -a 256 | cut -d' ' -f1
elif command -v sha256sum >/dev/null 2>&1; then
cat "$@" | sha256sum | cut -d' ' -f1
else
echo "missing shasum tool" 1>&2
exit 1
fi

0 comments on commit 7d62be1

Please sign in to comment.