HOST:=localhost
PORT:=5000
TAG:=latest
PROJECT:=anode
IMAGE:=$(PROJECT)/frontend/portal:$(TAG)

build:
	if [ -d "../common" ]; then rsync -a --exclude='.*' ../common/ ./src/common; fi
	docker build -t $(IMAGE) -f docker/Dockerfile .
	if [ -d "./src/common" ]; then  rm -r ./src/common; fi

push:
	docker tag $(IMAGE) $(HOST):$(PORT)/$(IMAGE)
	docker push $(HOST):$(PORT)/$(IMAGE)

build-dist:
	$(call ndef,ID)
	docker exec -it $(ID) ng build --configuration=production
	docker cp $(ID):/usr/src/app/dist /vagrant/portal

aws-sync-s3:
	aws s3 sync ./dist s3://anode.portal --delete

aws-invalidate-cf:
	aws cloudfront create-invalidation --distribution-id E38M4ZE548CLUJ --paths "/*"

update-prod:
	make build-dist
	make aws-sync-s3
	make aws-invalidate-cf