-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
87 lines (68 loc) · 2.79 KB
/
Makefile
File metadata and controls
87 lines (68 loc) · 2.79 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#----------------------------------------------------------------
# Tooling & Configuration
#----------------------------------------------------------------
SHELL := bash
COMMIT_HASH := $(shell git rev-parse --short=10 HEAD 2>/dev/null || echo "dev")
BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null | sed 's/[^a-zA-Z0-9]/-/g' || echo "local")
VERSION := $(BRANCH)-$(COMMIT_HASH)
SCRIPTS := ./scripts
.DEFAULT_GOAL := help
.PHONY: help setup dev build deploy-% plan-% apply-% validate-% destroy-% sops-%
#----------------------------------------------------------------
# Context Helpers
#----------------------------------------------------------------
get_stem = $(subst -, ,$*)
get_env = $(word 1,$(get_stem))
get_app = $(if $(word 2,$(get_stem)),$(lastword $(get_stem)),all)
# Inject secrets for <env>, then delegate to atmos.sh
run_atmos = $(SCRIPTS)/with-secrets.sh $(get_env) $(SCRIPTS)/atmos.sh
# ENV APP pair forwarded to atmos.sh for all standard targets
env_app = $(get_env) $(get_app)
# Install deps and run a bun script in the matching app directory
bun_app = cd $(CURDIR)/apps/$(get_app) && bun install && bun run
#----------------------------------------------------------------
# Targets
#----------------------------------------------------------------
## setup: validate tools and initialize SOPS
setup:
@$(SCRIPTS)/setup.sh
## deploy-[env]: deploy all infrastructure
deploy-%:
@$(run_atmos) bootstrap $(get_env) all
## plan-[env]-[comp]: terraform plan (omit comp to plan all)
plan-%:
@$(run_atmos) plan $(env_app)
## apply-[env]-[comp]: terraform apply (omit comp to apply all)
apply-%:
@$(run_atmos) apply $(env_app)
## validate-[env]-[comp]: static analysis (omit comp to validate all)
validate-%:
@$(run_atmos) validate $(env_app)
## destroy-[env]-[comp]: infrastructure destruction (omit comp to destroy all)
destroy-%:
@$(run_atmos) destroy $(env_app)
## dev-[comp]: start local development
dev-%:
@$(bun_app) dev
## build-[comp]: build production bundle locally
build-%:
@$(bun_app) build
## sops-setup: generate age key
sops-setup:
@$(SCRIPTS)/sops.sh setup
## sops-init-[env]: create sops config
sops-init-%:
@$(SCRIPTS)/sops.sh init $*
## sops-encrypt-[env]: encrypt files
sops-encrypt-%:
@$(SCRIPTS)/sops.sh encrypt $*
## sops-decrypt-[env]: decrypt files
sops-decrypt-%:
@$(SCRIPTS)/sops.sh decrypt $*
## help: show this menu
help:
@printf -- "========================================================================\n"
@printf -- " fabianpiper.com | Version: $(VERSION)\n"
@printf -- "========================================================================\n"
@grep -E '^## .*' $(MAKEFILE_LIST) | sed 's/## //' | awk -F': ' '{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@printf -- "========================================================================\n"