Skip to content

Latest commit

 

History

History
17 lines (14 loc) · 566 Bytes

make_file_with_git_version_on_node_project.mdx

File metadata and controls

17 lines (14 loc) · 566 Bytes
title date tag
Using Git Version on a Node Project in a Makefile for Docker Build
2021-06-21
make nodejs git docker
IMAGE ?= "<YOURIMAGENAMEHERE>"

# This will output something similar to `git describe --always --long`.
# This is being done because we need the build to happen before we are able to reliably tag a commit (due to squash and merge).
VERSION ?= "v$(shell node -e 'console.log(require("./package.json").version)')-g$(shell git rev-parse --short HEAD)"

.PHONY: docker-build
docker-build:
	docker build -t $(IMAGE):$(VERSION) .