Skip to content

Instantly share code, notes, and snippets.

@mkasberg
Created February 6, 2022 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkasberg/d22f32dfb3ccab4d231204f5185b8b3d to your computer and use it in GitHub Desktop.
Save mkasberg/d22f32dfb3ccab4d231204f5185b8b3d to your computer and use it in GitHub Desktop.
A Makefile for building Docker images - customize to suit your needs
.PHONY: help image test shell clean
DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " help Print this help message."
@echo " image Build the my-project:latest Docker image."
@echo " shell Open a shell inside the Docker container."
@echo " clean Remove the Docker image."
image:
docker build -t my-project:latest "${DIR}"
shell: image
docker run --rm -it -v "${DIR}":/root/my-project my-project:latest bash
clean:
docker rmi my-project:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment