generated from nullplatform/technology-templates-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (55 loc) · 2.09 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
#
# Makefile for processing assets
#
# This Makefile is designed to receive parameters that control its behavior.
# It helps manage assets by processing them in a specified working directory
# and outputting the results to a designated asset output directory.
# Parameter: ASSET_WORKING_DIRECTORY
# This is the directory where the assets will be processed from.
# This variable is set to the path of the directory containing your source assets.
# Parameter: ASSET_OUTPUT_DIRECTORY
# This is the directory where the processed assets will be stored.
# This variable is set to the path of the directory where the processed assets will be saved.
# Parameter: ASSET_TARGET_URL
# The remote repository URL where the processed assets will be pushed or deployed.
# This variable is set to the URL of the destination repository.
# Parameter: ASSET_NAME
# The name of the asset being processed. It is used to create the ASSET_FILE.
ASSET_FILE=$(ASSET_NAME).zip
.PHONY: build push
ifeq ($(ASSET_TYPE),lambda)
build: build-lambda
push: push-lambda
endif
ifeq ($(ASSET_TYPE),docker-image)
build: build-docker-image
push: push-docker-image
endif
#
# Lambda zip file
#
build-lambda: setup-lambda test-lambda compile-lambda package-lambda
clean-lambda:
rm -r $(ASSET_OUTPUT_DIRECTORY)
setup-lambda:
mkdir -p $(ASSET_OUTPUT_DIRECTORY)
cp $(ASSET_WORKING_DIRECTORY)/package.json $(ASSET_OUTPUT_DIRECTORY)
npm --prefix $(ASSET_OUTPUT_DIRECTORY) install --omit=dev
test-lambda:
npm --prefix $(ASSET_WORKING_DIRECTORY) install --only=dev
npm --prefix $(ASSET_WORKING_DIRECTORY) run test
compile-lambda:
cp $(ASSET_WORKING_DIRECTORY)/*.js $(ASSET_OUTPUT_DIRECTORY)
cp $(ASSET_WORKING_DIRECTORY)/*.ejs $(ASSET_OUTPUT_DIRECTORY)
package-lambda:
cd $(ASSET_OUTPUT_DIRECTORY) && zip -r $(ASSET_FILE) .
push-lambda:
aws s3 cp $(ASSET_OUTPUT_DIRECTORY)/$(ASSET_FILE) $(ASSET_TARGET_URL)
#
# Docker image
#
build-docker-image:
docker build $(BUILD_ARGS) -t $(ASSET_NAME) -f $(ASSET_WORKING_DIRECTORY)/Dockerfile $(BUILD_WORKING_DIRECTORY)
push-docker-image:
docker tag $(ASSET_NAME):latest $(ASSET_TARGET_URL)
docker push $(ASSET_TARGET_URL)