This repository has been archived by the owner on Nov 2, 2022. It is now read-only.
forked from puppetlabs-toy-chest/puppet-agent
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
55 lines (48 loc) · 2.16 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
NAMESPACE ?= puppet
git_describe = $(shell git describe)
vcs_ref := $(shell git rev-parse HEAD)
build_date := $(shell date -u +%FT%T)
hadolint_available := $(shell hadolint --help > /dev/null 2>&1; echo $$?)
hadolint_command := hadolint
hadolint_container := ghcr.io/hadolint/hadolint:latest
ubuntu_version := 18.04
export BUNDLE_PATH = $(PWD)/.bundle/gems
export BUNDLE_BIN = $(PWD)/.bundle/bin
export GEMFILE = $(PWD)/Gemfile
export DOCKER_BUILDKIT ?= 1
version = $(shell echo $(git_describe) | sed 's/-.*//')
dockerfile := Dockerfile
makefile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
makefile_dir := $(dir $(makefile_path))
LATEST_VERSION ?= latest
prep:
@git fetch --unshallow ||:
@git fetch origin 'refs/tags/*:refs/tags/*'
lint:
ifeq ($(hadolint_available),0)
@$(hadolint_command) puppet-agent-ubuntu/$(dockerfile)
else
@docker pull $(hadolint_container)
@docker run --rm -v $(PWD)/puppet-agent-ubuntu/$(dockerfile):/Dockerfile -i $(hadolint_container) $(hadolint_command) Dockerfile
endif
build: prep
docker pull ubuntu:$(ubuntu_version)
docker build ${DOCKER_BUILD_FLAGS} --build-arg ubuntu_version=$(ubuntu_version) --build-arg vcs_ref=$(vcs_ref) --build-arg build_date=$(build_date) --build-arg version=$(version) --file puppet-agent-ubuntu/$(dockerfile) --tag $(NAMESPACE)/puppet-agent-ubuntu:$(version) puppet-agent-ubuntu
@docker tag $(NAMESPACE)/puppet-agent-ubuntu:$(version) $(NAMESPACE)/puppet-agent:$(version)
ifeq ($(IS_LATEST),true)
@docker tag $(NAMESPACE)/puppet-agent-ubuntu:$(version) $(NAMESPACE)/puppet-agent-ubuntu:$(LATEST_VERSION)
@docker tag $(NAMESPACE)/puppet-agent-ubuntu:$(version) $(NAMESPACE)/puppet-agent:$(LATEST_VERSION)
endif
test: prep
@bundle install --path $$BUNDLE_PATH --gemfile $$GEMFILE --with test
@bundle update
@PUPPET_TEST_DOCKER_IMAGE=$(NAMESPACE)/puppet-agent-ubuntu:$(version) \
bundle exec --gemfile $$GEMFILE rspec spec
publish: prep
@docker push $(NAMESPACE)/puppet-agent-ubuntu:$(version)
@docker push $(NAMESPACE)/puppet-agent:$(version)
ifeq ($(IS_LATEST),true)
@docker push $(NAMESPACE)/puppet-agent-ubuntu:$(LATEST_VERSION)
@docker push $(NAMESPACE)/puppet-agent:$(LATEST_VERSION)
endif
.PHONY: lint build test publish