forked from plus3it/spel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (51 loc) · 2.42 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
56
57
58
59
60
61
62
63
64
65
66
67
SHELL := /bin/bash
PACKER_ZIP ?= https://releases.hashicorp.com/packer/$(PACKER_VERSION)/packer_$(PACKER_VERSION)_linux_amd64.zip
PACKER_LOG ?= '1'
PACKER_LOG_PATH = .spel/$(SPEL_VERSION)/packer.log
CHECKPOINT_DISABLE ?= '1'
SPEL_CI ?= false
SPEL_BUILDERS ?= amazon-ebs.minimal-rhel-7-hvm,amazon-ebs.minimal-centos-7-hvm,amazon-ebs.minimal-rhel-8-hvm,amazon-ebs.minimal-centos-8stream-hvm,amazon-ebs.minimal-ol-8-hvm
export PATH := $(HOME)/bin:$(PATH)
# The `pre_build`, `build`, and `post_build` targets all use packer in a way that
# supports both Commercial and GovCloud partitions. For GovCloud, the `install`
# target is used to setup an aws profile with credentials retrieved from SSM. For
# the Commercial partition, the profile is created but the credentials are sourced
# from the execution environment (meaning your workstation or CodeBuild).
# Due to the use of an aws profile, when running interactively, it is required
# to export AWS_PROFILE with a valid profile. For CodeBuild CI, it is set to $SPEL_IDENTIFIER,
# and `make install` will create it.
.PHONY: all install pre_build build post_build docs
.EXPORT_ALL_VARIABLES:
$(info SPEL_IDENTIFIER=$(SPEL_IDENTIFIER))
$(info SPEL_VERSION=$(SPEL_VERSION))
ifndef SPEL_IDENTIFIER
$(error SPEL_IDENTIFIER is not set)
endif
ifndef SPEL_VERSION
$(error SPEL_VERSION is not set)
else
$(shell mkdir -p ".spel/$(SPEL_VERSION)")
endif
all: build
docs/lint:
$(MAKE) -f Makefile.tardigrade-ci docs/lint
docs/generate:
$(MAKE) -f Makefile.tardigrade-ci docs/generate
install:
$(MAKE) -f Makefile.tardigrade-ci packer/install
bash -eo pipefail ./build/install.sh
# The profile and region envs are used only by the `pre_build`, `build`, and `post_build`
# targets. For the region targets, do not use "?=" because we *always* want to
# override this in codebuild. We cannot set these in the buildspec because that
# breaks codebuild when building for GovCloud.
pre_build build post_build: export AWS_PROFILE ?= $(SPEL_IDENTIFIER)
pre_build build post_build: export AWS_DEFAULT_REGION := $(or $(PKR_VAR_aws_region),$(AWS_REGION))
pre_build build post_build: export AWS_REGION := $(or $(PKR_VAR_aws_region),$(AWS_REGION))
# Set the source security group cidr
pre_build build post_build: export PKR_VAR_aws_temporary_security_group_source_cidrs = ["$(shell curl -sSL https://api.ipify.org)/32"]
pre_build:
bash ./build/pre_build.sh
build: pre_build
bash ./build/build.sh
post_build:
bash ./build/post_build.sh