Makefile 2.79 KB
Newer Older
yhua's avatar
yhua committed
1 2 3 4
# Makefile for a harbor project
#	
# Targets:
#
yhua's avatar
yhua committed
5
# build: 	build harbor photon images
6
# clean:	clean adminserver, ui and jobservice harbor images
yhua's avatar
yhua committed
7 8 9 10

# common
SHELL := /bin/bash
BUILDPATH=$(CURDIR)
11 12
MAKEPATH=$(BUILDPATH)/make
MAKEDEVPATH=$(MAKEPATH)/dev
yhua's avatar
yhua committed
13 14 15
SRCPATH=./src
TOOLSPATH=$(BUILDPATH)/tools
CHECKENVCMD=checkenv.sh
16
DEVFLAG=true
yhua's avatar
yhua committed
17 18 19 20 21 22 23 24

# docker parameters
DOCKERCMD=$(shell which docker)
DOCKERBUILD=$(DOCKERCMD) build
DOCKERRMIMAGE=$(DOCKERCMD) rmi
DOCKERIMASES=$(DOCKERCMD) images

# binary 
25 26 27
ADMINSERVERSOURCECODE=$(SRCPATH)/adminserver
ADMINSERVERBINARYPATH=$(MAKEDEVPATH)/adminserver
ADMINSERVERBINARYNAME=harbor_adminserver
yhua's avatar
yhua committed
28
UISOURCECODE=$(SRCPATH)/ui
29
UIBINARYPATH=$(MAKEDEVPATH)/ui
yhua's avatar
yhua committed
30 31
UIBINARYNAME=harbor_ui
JOBSERVICESOURCECODE=$(SRCPATH)/jobservice
32
JOBSERVICEBINARYPATH=$(MAKEDEVPATH)/jobservice
yhua's avatar
yhua committed
33 34
JOBSERVICEBINARYNAME=harbor_jobservice

yhua's avatar
yhua committed
35 36
# photon dockerfile
DOCKERFILEPATH=$(MAKEPATH)/photon
37 38 39
DOCKERFILEPATH_ADMINSERVER=$(DOCKERFILEPATH)/adminserver
DOCKERFILENAME_ADMINSERVER=Dockerfile
DOCKERIMAGENAME_ADMINSERVER=vmware/harbor-adminserver
yhua's avatar
yhua committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
DOCKERFILEPATH_UI=$(DOCKERFILEPATH)/ui
DOCKERFILENAME_UI=Dockerfile
DOCKERIMAGENAME_UI=vmware/harbor-ui
DOCKERFILEPATH_JOBSERVICE=$(DOCKERFILEPATH)/jobservice
DOCKERFILENAME_JOBSERVICE=Dockerfile
DOCKERIMAGENAME_JOBSERVICE=vmware/harbor-jobservice
DOCKERFILEPATH_LOG=$(DOCKERFILEPATH)/log
DOCKERFILENAME_LOG=Dockerfile
DOCKERIMAGENAME_LOG=vmware/harbor-log

# version prepare
VERSIONFILEPATH=$(SRCPATH)/views/sections
VERSIONFILENAME=header-content.htm
GITCMD=$(shell which git)
GITTAG=$(GITCMD) describe --tags
55 56 57 58 59
ifeq ($(DEVFLAG), true)        
	VERSIONTAG=dev
else        
	VERSIONTAG=$(shell $(GITTAG))
endif
yhua's avatar
yhua committed
60 61

check_environment:
62
	@$(MAKEPATH)/$(CHECKENVCMD)
yhua's avatar
yhua committed
63

yhua's avatar
yhua committed
64
build: 
65 66 67 68
	@echo "building adminserver container for photon..."
	$(DOCKERBUILD) -f $(DOCKERFILEPATH_ADMINSERVER)/$(DOCKERFILENAME_ADMINSERVER) -t $(DOCKERIMAGENAME_ADMINSERVER):$(VERSIONTAG) .
	@echo "Done."

yhua's avatar
yhua committed
69
	@echo "building ui container for photon..."
yhua's avatar
yhua committed
70 71 72
	$(DOCKERBUILD) -f $(DOCKERFILEPATH_UI)/$(DOCKERFILENAME_UI) -t $(DOCKERIMAGENAME_UI):$(VERSIONTAG) .
	@echo "Done."
	
yhua's avatar
yhua committed
73
	@echo "building jobservice container for photon..."
yhua's avatar
yhua committed
74 75 76
	$(DOCKERBUILD) -f $(DOCKERFILEPATH_JOBSERVICE)/$(DOCKERFILENAME_JOBSERVICE) -t $(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG) .
	@echo "Done."
	
yhua's avatar
yhua committed
77
	@echo "building log container for photon..."
yhua's avatar
yhua committed
78 79 80 81
	$(DOCKERBUILD) -f $(DOCKERFILEPATH_LOG)/$(DOCKERFILENAME_LOG) -t $(DOCKERIMAGENAME_LOG):$(VERSIONTAG) .
	@echo "Done."
	
cleanimage:
yhua's avatar
yhua committed
82
	@echo "cleaning image for photon..."
83
	- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_ADMINSERVER):$(VERSIONTAG)
yhua's avatar
yhua committed
84 85 86 87 88 89 90
	- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_UI):$(VERSIONTAG)
	- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_JOBSERVICE):$(VERSIONTAG)
	- $(DOCKERRMIMAGE) -f $(DOCKERIMAGENAME_LOG):$(VERSIONTAG)
	
.PHONY: clean
clean: cleanimage