This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (68 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
# See: http://clarkgrubb.com/makefile-style-guide
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := default
.DELETE_ON_ERROR :
.SUFFIXES :
STASH := stash
PROJECT := vamp-workflow-agent
PROJECT_DIR := $(CURDIR)
VERSION := $(shell git describe --tags)
TARGET := $(CURDIR)/target
IMAGE_TAG := $(shell echo $$BRANCH_NAME)
# if Makefile.local exists, include it.
ifneq ("$(wildcard Makefile.local)", "")
include Makefile.local
endif
ifeq ($(strip $(IMAGE_TAG)),)
IMAGE_TAG := $(shell git rev-parse --abbrev-ref HEAD)
endif
.PHONY: clean
clean:
rm -rf $(TARGET)
.PHONY: tag
tag:
@echo $(IMAGE_TAG)
.PHONY: version
version:
@echo $(VERSION)
.PHONY: frontend
frontend:
@cd $(CURDIR)/ui && make STASH=$(STASH) PROJECT_DIR=$(PROJECT_DIR) local
.PHONY: backend
backend:
uname -a
@go version
@echo "$(PROJECT): $(VERSION)"
go get -d -v ./...
go install -v ./...
go build -ldflags "-X main.version=$(VERSION)" -a -installsuffix cgo
.PHONY: build
build:
@cd $(CURDIR)/ui && make purge
docker run \
--rm \
--volume $(STASH):/go \
--volume $(PROJECT_DIR):/go/src/github.com/magneticio/$(PROJECT) \
--workdir=/go/src/github.com/magneticio/$(PROJECT) \
golang:1.10.2 make STASH=$(STASH) PROJECT_DIR=$(PROJECT_DIR)/ui backend
@cd $(CURDIR)/ui && \
docker run \
--rm \
--volume $(STASH):/root \
--volume $(PROJECT_DIR)/ui:/$(PROJECT) \
--workdir=/$(PROJECT) \
node:9.11.1 make local
mkdir -p $(TARGET)
echo $(VERSION) > $(TARGET)/version
cp $(CURDIR)/package.json $(CURDIR)/yarn.lock $(CURDIR)/Dockerfile $(TARGET)/ && cp -R $(CURDIR)/files $(TARGET)/
mv $(CURDIR)/$(PROJECT) $(TARGET)/. && mv $(CURDIR)/ui/dist $(TARGET)/ui
docker run \
--rm \
--volume $(STASH):/root \
--volume $(TARGET):/$(PROJECT) \
--workdir=/$(PROJECT) \
node:9.11.1 yarn install
docker build -t magneticio/$(PROJECT):$(IMAGE_TAG) $(TARGET)
.PHONY: default
default: clean build