-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
46 lines (40 loc) · 1.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
SHELL := /bin/bash
IMAGE_NAME = mipnw/alpine
TAG ?= 3.12
THIS_DIR = $(shell pwd)
DOCKER_ARGS := --env LOCAL_USER_ID=$(shell id -u)
DOCKER_ARGS := $(DOCKER_ARGS) --env LOCAL_GROUP_ID=$(shell id -g)
DOCKER_ARGS := $(DOCKER_ARGS) --env ROOT=$(ROOT)
DOCKER_ARGS := $(DOCKER_ARGS) --workdir /$(IMAGE_NAME)
DOCKER_ARGS := $(DOCKER_ARGS) --volume $(THIS_DIR)/projects:/$(IMAGE_NAME)
ifdef DOCKER_USER_PATH
DOCKER_ARGS := $(DOCKER_ARGS) --volume $(DOCKER_USER_PATH):/mnt/appuser:ro
endif
.PHONY: help
help:
@echo 'Usage: make [target] [options]'
@echo 'Build and use the Alpine base'
@echo
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
ifndef VERBOSE
.SILENT:
endif
.dockerimage.$(TAG): $(TAG)/Dockerfile $(shell find scripts -type f)
docker build \
--force-rm \
-f $(TAG)/Dockerfile \
-t $(IMAGE_NAME):$(TAG) \
$(THIS_DIR)
touch .dockerimage.$(TAG)
build: .dockerimage.$(TAG) ## builds the docker image
.PHONY: shell
shell: .dockerimage.$(TAG) ## shells into the docker container
docker run --rm -it \
--hostname devbox \
$(DOCKER_ARGS) \
$(IMAGE_NAME):$(TAG) \
/bin/bash
.PHONY: clean
clean: ## cleans your host of development artifacts
-docker image rm -f $(IMAGE_NAME):$(TAG) &> /dev/null
-rm .dockerimage.$(TAG) &> /dev/null