This repository has been archived by the owner on Sep 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
66 lines (48 loc) · 1.89 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
#!make
VERSION=$(shell ./.version.sh)
BUILDPATH=$(shell pwd)/build
OUT=$(shell pwd)/out
NAME = team1533/strangescout
IMG = $(NAME):$(VERSION)
LATEST = $(NAME):latest
EDGE = $(NAME):edge
out:
@printf "\n Creating build directories\n";
mkdir -p $(BUILDPATH)/frontend
mkdir -p $(BUILDPATH)/output
@printf "\n Copying sources\n";
cd server; tar cf - --exclude='node_modules' --exclude='static' --exclude='dbs/*' * | ( cd $(BUILDPATH)/output; tar xfp -)
cd frontend/web; tar cf - --exclude='node_modules' --exclude='dist' * | ( cd $(BUILDPATH)/frontend; tar xfp -)
@printf "\n Setting version %s\n" "$(VERSION)";
sed -i s/0.0.0/$(VERSION)/ $(BUILDPATH)/frontend/src/environments/environment.prod.ts;
@printf "\n Installing frontend dependencies\n";
@cd $(BUILDPATH)/frontend; \
npm i;
@printf "\n Copying build leveldown dep to output\n";
mkdir -p $(BUILDPATH)/output/node_modules/
cp -r $(BUILDPATH)/frontend/node_modules/leveldown $(BUILDPATH)/output/node_modules/leveldown
@printf "\n Building frontend\n";
@cd $(BUILDPATH)/frontend; \
./node_modules/.bin/ng build --prod --aot --source-map=false --build-optimizer --progress --output-path=$(BUILDPATH)/output/static;
@printf "\n Installing server dependencies\n";
@cd $(BUILDPATH)/output; \
npm i --production;
@printf "\n Patching server PouchDB\n";
@cd $(BUILDPATH)/output; \
patch node_modules/express-pouchdb/lib/routes/session.js session.patch;
@printf "\n Relocating output\n";
mv $(BUILDPATH)/output $(OUT);
@printf "\n Cleaning build files\n";
rm -rf $(BUILDPATH);
@printf "\n Creating version file\n";
echo $(VERSION) > $(OUT)/version;
@printf "\n Done!";
.PHONY: clean docker
clean:
@echo " Cleaning...";
rm -rf $(BUILDPATH);
rm -rf $(OUT);
docker: out
docker image build -f docker/Dockerfile -t $(IMG) ./
docker tag $(IMG) $(EDGE)
if git describe --tags --exact-match > /dev/null 2>&1; then docker tag $(IMG) $(LATEST); fi