Skip to content

Instantly share code, notes, and snippets.

@smailq
Created October 17, 2016 19:01
Show Gist options
  • Save smailq/34bc0c207cfd3c05a633acb1ec423de8 to your computer and use it in GitHub Desktop.
Save smailq/34bc0c207cfd3c05a633acb1ec423de8 to your computer and use it in GitHub Desktop.
Simple Makefile for maintaining a Docker image
# Get git commit SHA
GIT_COMMIT = $(shell git rev-parse HEAD)
# Build docker image
build:
docker build -f Dockerfile -t someorg/myproject:$(GIT_COMMIT) .
# Run docker image, exposing port 80 of container image to port 80 of the host
run:
docker run --name myproject -p 80:80 -d someorg/myproject:$(GIT_COMMIT)
# Stop running container and remove the name
stop:
docker stop myproject
docker rm myproject
# Pull from git remote, fast forward merge only
pull:
@date
@git pull --ff-only
@echo "-------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment