Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker makefile #1553

Merged
merged 2 commits into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions docs/deploy-from-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ $ docker run --cap-drop=all -it \
trailofbits/algo:latest
```

## GNU Makefile for Docker

You can also build and deploy with a Makefile. This simplifies some of the command strings and opens the door for further user configuration.

The `Makefile` consists of three targets: `docker-build`, `docker-deploy`, and `docker-prune`.
`docker-all` will run thru all of them.

## Building Your Own Docker Image

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.
Expand Down