-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMakefile
86 lines (61 loc) · 2.02 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
UID = $(shell id -u)
GID = $(shell id -g)
CC = docker-compose
TAG="latest"
DEVDC=-f docker-compose-dev.yaml
prod: .env build
docker-compose up
dev: .env
$(CC) $(DEVDC) up --remove-orphans --build
.env:
echo "_GID=$(_GID)" > $@
echo "_UID=$(_UID)" >> $@
build: .env containers/prod/app containers/prod/ui
# build the needed images to build ui and go binary
$(CC) $(DEVDC) build
# tag imannotate image
cd containers/prod/ && docker build -t smileinnovation/imannotate:$(TAG) .
enter-api:
$(CC) $(DEVDC) exec api sh
enter-ui:
$(CC) $(DEVDC) exec ui sh
containers/prod/ui:
$(CC) $(DEVDC) run --rm ui ng build --prod
mv ui/dist containers/prod/ui
containers/prod/app:
echo 'go build -ldflags "-linkmode external -extldflags -static" -o app.bin' > app/builder.sh
$(CC) $(DEVDC) run --rm api sh ./builder.sh
mv app/app.bin containers/prod/app
rm app/builder.sh
# remove all, volumes, dist, binaries and images
clean-all: clean-volumes clean clean-images
# remove dists and binariez
clean: clean-container-dist
rm -f app/builder.sh
rm -rf ui/dist
rm -f app/gin-bin app/app.bin
# remove containers to build dis
clean-container-dist: clean-ui-container-dist clean-api-container-dist
clean-ui-container-dist:
rm -rf containers/prod/ui
clean-api-container-dist:
rm -rf containers/prod/app
# remove containers (not images) and orphanss
clean-docker:
docker-compose down --remove-orphans
$(CC) $(DEVDC) down --remove-orphans
# remove containers (not images) and orphans + volumes
clean-volumes:
docker-compose down -v --remove-orphans
$(CC) $(DEVDC) down -v --remove-orphans
# remove images
clean-images:
docker rmi $(shell docker image ls -q $(notdir $(shell pwd))*) || :
docker rmi smileinnovation/imannotate:$(TAG)
virtualenv:
mkdir -p ./src/github.com/imannotate
ln -sf $$PWD/app ./src/github.com/imannotate/app
ln -sf $$PWD/api ./src/github.com/imannotate/api
@echo "Environment ready to be used with goswitch or with GOPATH=\$$GOPATH:\$$PWD and PATH=\$$PATH:\$$PWD/bin"
test:
go test -v ./api/... ./app/server/...