Skip to content

Instantly share code, notes, and snippets.

@sjeandeaux
Last active August 29, 2015 14:22
Show Gist options
  • Save sjeandeaux/5da22687201fec6c771a to your computer and use it in GitHub Desktop.
Save sjeandeaux/5da22687201fec6c771a to your computer and use it in GitHub Desktop.
Docker and Makefile
#
# You need to define
# tag
# littleName
# environment
# publish
# registry
registry=
current_dir = $(shell pwd)
bigTag=$(registry)$(tag)
dockerfile=Dockerfile
command=
commandExec=
host = $(shell if [ -n "$(shell which boot2docker)" ]; then boot2docker ip; else echo 127.0.0.1; fi)
#MAC boot2docker , linux => ifconfig...
docker_host = $(shell if [ -n "$(shell which boot2docker)" ]; then boot2docker ip; else ifconfig docker0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'; fi)
#TODO wiki explain function docker-proxy-file
determineDockerfile = $(shell if [ -f "$(current_dir)/../docker-proxy-file" ]; then $(current_dir)/../docker-proxy-file $(dockerfile); else echo $(dockerfile); fi)
build:
docker build -t $(bigTag) -f $(call determineDockerfile) .
rm:
docker rm -f $(littleName)
stop:
docker stop $(littleName)
rmi:
docker rmi -f $(bigTag)
logs:
docker logs $(littleName)
exec:
docker exec -ti $(littleName) $(commandExec)
run:
docker run -d --name $(littleName) $(environnement) $(publish) $(bigTag) $(command)
push:
docker push $(bigTag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment