Skip to content

Commit

Permalink
fix: portability Linux/Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
casparderksen committed Jan 2, 2019
1 parent 0808ca6 commit e93ad83
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
TAG = my/oradb
TAG = my/oradb
IMAGE = oracle/database:12.2.0.1-ee
FILE = images/oradb-12201-ee.tgz

ifeq ($(shell uname -s), Linux)
XARGS_ARGS = --no-run-if-empty
ZCAT = zcat
else
XARGS_ARGS =
ZCAT = gzcat
endif

.PHONY: default
default: build

Expand All @@ -17,15 +25,15 @@ run: build

.PHONY: logs
logs:
docker ps -q -f ancestor=$(TAG) | xargs docker logs -f
docker ps -q -f ancestor=$(TAG) | xargs $(XARGS_ARGS) docker logs -f

.PHONY: stop
stop:
-docker ps -q -f ancestor=$(TAG) | xargs docker stop
-docker ps -q -f ancestor=$(TAG) | xargs $(XARGS_ARGS) docker stop

.PHONY: rm
rm: stop
-docker ps -a -q -f ancestor=$(TAG) | xargs docker rm -f
-docker ps -a -q -f ancestor=$(TAG) | xargs $(XARGS_ARGS) docker rm -f

.PHONY: rmi
rmi:
Expand All @@ -37,15 +45,15 @@ save:

.PHONY: load
load:
gzcat $(FILE) | docker load
$(ZCAT) $(FILE) | docker load

.PHONY: clean
clean: stop rmi

.PHONY: clobber
clobber: clean
-docker images | tail -n +2 | awk '$$1 == "<none>" {print $$3}' | xargs docker rmi -f
-docker images | tail -n +2 | awk '$$1 == "<none>" {print $$3}' | xargs $(XARGS_ARGS) docker rmi -f

.PHONY: pristine
pristine: clobber
-docker volume rm -f oradata
-docker volume rm -f oradata

0 comments on commit e93ad83

Please sign in to comment.