-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (53 loc) · 1.8 KB
/
Makefile
File metadata and controls
66 lines (53 loc) · 1.8 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Makefile to build docker image & push to hub.docker.com
# very helpful original :
# https://gist.github.com/mpneuried/0594963ad38e68917ef189b4e6a269db
# pmcampbell
# 2020-2-19
include config.make
#export $(shell sed 's/=.*//' $(cnf))
# .PHONY used if no options given
.PHONY: help
help: ## help info here
@echo Makefile for container $(RUN_NAME)
@echo clone: $(GIT_REPO)
@echo build: $(CONTAINER_IMAGE)
@echo run: $(RUN_NAME)
@echo port forward on run container:$(CONTAINER_PORT) to host:$(HOST_PORT)
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
# clone (need keys, or interactive w uid/pass)
clone: ## create tarball from app directory
# if [ -d app ] ; then rm -rf app; fi
# mkdir app; git clone $(GIT_REPO) app
tar -czf app.tgz app
build: ## build container image from Dockerfile
docker build -t $(CONTAINER_IMAGE) .
run-fg: ## run the container, logs to stdout
docker run -p $(HOST_PORT):$(CONTAINER_PORT) --name $(RUN_NAME) $(CONTAINER_IMAGE)
run: ## run the container, detached (~in the background )
docker run -d -p $(HOST_PORT):$(CONTAINER_PORT) --name $(RUN_NAME) $(CONTAINER_IMAGE)
docker ps
sh: shell
shell: ## shell into the container
docker exec -ti $(RUN_NAME) sh
all: clone build run
up: build run
clean: stop prune
stoprun: stop run
stop: ## stop and remove the container
docker stop $(RUN_NAME) ; docker rm $(RUN_NAME) ; docker ps
prune: # clean up unused containers
docker system prune -f
docker images
check: ## check docker run time
systemctl status docker
docker version
docker images
docker ps
publish:
@echo publish to docker hub, interactive
ifdef DOCKER_USER
docker login -u $(DOCKER_USER)
else
docker login
endif
docker image push $(CONTAINER_IMAGE):latest