-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (52 loc) · 1.95 KB
/
Makefile
File metadata and controls
63 lines (52 loc) · 1.95 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
# makefile to build a container to run firefox
# pmcampbell
# 2020-04-16
include config.make
XAUTH := ~/.Xauthority
# .PHONY used if no options given
.PHONY: help
@echo set up firefox container for faceborg
help: ## put help info here
@echo
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
all: build run ## build and run
build: ## build container image from Dockerfile
docker build -t $(CONTAINER_IMAGE) . -f $(DOCKERFILE)
run: ## run the container, interactive
# -i interactive (used for testing)
# --rm container is ephemeral (used for testing)
# -t pseudo tty attached to stdin of container (defaults to false)
# not needed, host has authority
# xhost +
# if you omit the --net=host, you will get the error:
# Error: Can't open display:
docker run --net=host --rm -e DISPLAY=${DISPLAY} -v ${XAUTH}:/root/.Xauthority --name $(RUN_NAME) $(CONTAINER_IMAGE)
sh: shell ## use shell
# --rm removed so container remains & we can shell into it
shell: ## shell into the container
docker run -ti --net=host -e DISPLAY=${DISPLAY} -v ${XAUTH}:/root/.Xauthority --name $(RUN_NAME) $(CONTAINER_IMAGE)
docker exec -ti $(RUN_NAME) -e DISPLAY=${DISPLAY} -v ${XAUTH}:/root/.Xauthority sh
logs: ## show logs for the containers
docker logs -f $(RUN_NAME)
restart: stoprun ## use stop then run
clean: stop prune ## use stop then prune
stop: ## stop and remove the containers
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 info
docker version
docker images
docker ps
docker-compose version
publish:
@echo publish to docker hub, interactive
@echo be sure to tag it first with my repo tricia/imagename
ifdef DOCKER_USER
docker login -u $(DOCKER_USER)
else
docker login
endif
docker image push $(CONTAINER_IMAGE):latest