-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (38 loc) · 1.5 KB
/
Copy pathMakefile
File metadata and controls
51 lines (38 loc) · 1.5 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
BOX_DIR ?= boxes
BOX_PREFIX ?= django
BOX_VERSION ?= $(shell cat VERSION)
BOX_PATH := $(BOX_DIR)/$(BOX_PREFIX)-$(BOX_VERSION).box
S3_PREFIX ?= s3://transcode-vagrantcloud/virtualbox
S3_PATH := $(S3_PREFIX)/$(BOX_PREFIX)-$(BOX_VERSION).box
VAGRANT_ID_PATH := .vagrant/machines/default/virtualbox/id
VENV := .venv
AWSCLI := $(VENV)/bin/aws
PIP_INSTALL := $(VENV)/bin/python3 -m pip install
.DEFAULT_GOAL := help
.PHONY: help all build clean clean-venv package upload
help:
@grep -E '^[\.a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
all: clean build package upload ## Build, package and upload the re-usable box
$(VAGRANT_ID_PATH):
vagrant up
cat cleanup.log
build: $(VAGRANT_ID_PATH) ## Create, configure and provision the Vagrant box
clean: ## Destroy the Vagrant box and delete the re-usable box
vagrant destroy --force
rm -f $(BOX_PATH)
rm -f cleanup.log
clean-venv: ## Delete the virtual Python environment
rm -rf $(VENV)
$(BOX_PATH):
mkdir -p $(BOX_DIR)
vagrant package --vagrantfile Vagrantfile.package --output $(BOX_PATH)
package: $(BOX_PATH) ## Package the currently running VirtualBox environment into a re-usable box
ls -hl $(BOX_PATH)
$(VENV):
python3 -m venv $(VENV)
$(PIP_INSTALL) --upgrade pip setuptools wheel
$(AWSCLI): $(VENV)
$(PIP_INSTALL) --requirement requirements.pip
upload: $(AWSCLI) ## Upload the re-usable box to a Amazon S3 bucket
$(AWSCLI) s3 cp $(BOX_PATH) $(S3_PATH)
$(AWSCLI) s3 ls $(S3_PREFIX)/