Skip to content

Commit fe19859

Browse files
johnwesleyjackivanov
authored andcommitted
Docker makefile (trailofbits#1553)
* makefile for docker deploys * update docs for makefile
1 parent 655729e commit fe19859

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

Makefile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## docker-build: Build and tag a docker image
2+
.PHONY: docker-build
3+
4+
IMAGE := trailofbits/algo
5+
TAG := latest
6+
DOCKERFILE := Dockerfile
7+
CONFIGURATIONS := $(shell pwd)
8+
9+
docker-build:
10+
docker build \
11+
-t $(IMAGE):$(TAG) \
12+
-f $(DOCKERFILE) \
13+
.
14+
15+
## docker-deploy: Mount config directory and deploy Algo
16+
.PHONY: docker-deploy
17+
18+
# '--rm' flag removes the container when finished.
19+
docker-deploy:
20+
docker run \
21+
--cap-drop=all \
22+
--rm \
23+
-it \
24+
-v $(CONFIGURATIONS):/data \
25+
$(IMAGE):$(TAG)
26+
27+
## docker-clean: Remove images and containers.
28+
.PHONY: docker-prune
29+
30+
docker-prune:
31+
docker images \
32+
$(IMAGE) |\
33+
awk '{if (NR>1) print $$3}' |\
34+
xargs docker rmi
35+
36+
## docker-all: Build, Deploy, Prune
37+
.PHONY: docker-all
38+
39+
docker-all: docker-build docker-deploy docker-prune

docs/deploy-from-docker.md

+7
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ $ docker run --cap-drop=all -it \
4646
trailofbits/algo:latest
4747
```
4848

49+
## GNU Makefile for Docker
50+
51+
You can also build and deploy with a Makefile. This simplifies some of the command strings and opens the door for further user configuration.
52+
53+
The `Makefile` consists of three targets: `docker-build`, `docker-deploy`, and `docker-prune`.
54+
`docker-all` will run thru all of them.
55+
4956
## Building Your Own Docker Image
5057

5158
You can use the Dockerfile provided in this repository as-is, or modify it to suit your needs. Further instructions on building an image can be found in the [Docker engine](https://docs.docker.com/engine/) documents.

0 commit comments

Comments
 (0)