Skip to content

Instantly share code, notes, and snippets.

@benfavre
Forked from f440/Makefile
Created February 27, 2017 00:26
Show Gist options
  • Save benfavre/29aafb4b6b3a9c04ba57d995d2903c97 to your computer and use it in GitHub Desktop.
Save benfavre/29aafb4b6b3a9c04ba57d995d2903c97 to your computer and use it in GitHub Desktop.
Makefile for docker project
NS ?= $(shell whoami)
REPO ?= $(shell basename $(shell pwd))
VERSION ?= latest
CONTAINER = $(NS)-$(REPO)
.PHONY: build
build:
docker build -t $(NS)/$(REPO):$(VERSION) .
.PHONY: push
push:
docker push -t $(NS)/$(REPO):$(VERSION)
.PHONY: shell
shell:
docker run -i -t --rm --name $(CONTAINER) --entrypoint /bin/sh $(NS)/$(REPO):$(VERSION) /bin/bash
.PHONY: run
run:
docker run -i -t --rm --name $(CONTAINER) $(NS)/$(REPO):$(VERSION)
.PHONY: start
start:
docker run -d --name $(CONTAINER) $(NS)/$(REPO):$(VERSION)
.PHONY: stop
stop:
docker stop $(CONTAINER)
.PHONY: rm
rm:
docker rm $(CONTAINER)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment