Created
February 6, 2022 17:07
-
-
Save mkasberg/d22f32dfb3ccab4d231204f5185b8b3d to your computer and use it in GitHub Desktop.
A Makefile for building Docker images - customize to suit your needs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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