From e1b2e9edd81120d7d887d2ce83755b55ab990df6 Mon Sep 17 00:00:00 2001 From: johnwesley Date: Sun, 18 Aug 2019 13:45:59 +0200 Subject: [PATCH] makefile for docker deploys --- Makefile | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0ef19ce --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +## docker-build: Build and tag a docker image +.PHONY: docker-build + +IMAGE := trailofbits/algo +TAG := latest +DOCKERFILE := Dockerfile +CONFIGURATIONS := $(shell pwd) + +docker-build: + docker build \ + -t $(IMAGE):$(TAG) \ + -f $(DOCKERFILE) \ + . + +## docker-deploy: Mount config directory and deploy Algo +.PHONY: docker-deploy + +# '--rm' flag removes the container when finished. +docker-deploy: + docker run \ + --cap-drop=all \ + --rm \ + -it \ + -v $(CONFIGURATIONS):/data \ + $(IMAGE):$(TAG) + +## docker-clean: Remove images and containers. +.PHONY: docker-prune + +docker-prune: + docker images \ + $(IMAGE) |\ + awk '{if (NR>1) print $$3}' |\ + xargs docker rmi + +## docker-all: Build, Deploy, Prune +.PHONY: docker-all + +docker-all: docker-build docker-deploy docker-prune