2017-08-29 01:35:05 +00:00
|
|
|
DOCKER_REPO ?= vividboarder
|
|
|
|
DOCKER_TAG ?= rpi-homebridge
|
|
|
|
DOCKER_TAG_DEV ?= $(DOCKER_TAG)-dev
|
|
|
|
HOMEBRIDGE_USER ?= root
|
|
|
|
|
2017-11-21 05:22:44 +00:00
|
|
|
.PHONY: default
|
2016-11-15 01:01:34 +00:00
|
|
|
default: build
|
|
|
|
|
|
|
|
# Default target to build the image
|
2017-11-21 05:22:44 +00:00
|
|
|
.PHONY: build
|
2016-11-14 22:41:21 +00:00
|
|
|
build:
|
2017-08-29 01:35:05 +00:00
|
|
|
docker build -t $(DOCKER_TAG_DEV) .
|
2016-11-14 22:41:21 +00:00
|
|
|
|
2016-11-15 01:01:34 +00:00
|
|
|
# Target to build and run and subsequently remove image
|
2017-11-21 05:22:44 +00:00
|
|
|
.PHONY: run
|
2016-11-14 22:41:21 +00:00
|
|
|
run: build
|
|
|
|
docker run --net=host --rm \
|
2017-08-29 01:35:05 +00:00
|
|
|
-p "51826:51826" \
|
|
|
|
-v "$(shell pwd)/config.json:/$(HOMEBRIDGE_USER)/.homebridge/config.json" \
|
|
|
|
-v "$(shell pwd)/plugins.txt:/$(HOMEBRIDGE_USER)/.homebridge/plugins.txt" \
|
|
|
|
$(DOCKER_TAG_DEV)
|
2016-11-14 22:41:21 +00:00
|
|
|
|
2016-11-15 01:01:34 +00:00
|
|
|
# Target to drop into an interractive shell
|
2017-11-21 05:22:44 +00:00
|
|
|
.PHONY: shell
|
2016-11-14 22:41:21 +00:00
|
|
|
shell: build
|
|
|
|
docker run --net=host --rm \
|
2017-08-29 01:35:05 +00:00
|
|
|
-p "51826:51826" \
|
|
|
|
-v "$(shell pwd)/config.json:/$(HOMEBRIDGE_USER)/.homebridge/config.json" \
|
|
|
|
-v "$(shell pwd)/plugins.txt:/$(HOMEBRIDGE_USER)/.homebridge/plugins.txt" \
|
2017-11-21 05:22:44 +00:00
|
|
|
$(shell grep -q '^RUN.*cross-build-start' Dockerfile && echo '-v "/usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static"') \
|
2017-08-29 01:35:05 +00:00
|
|
|
-it $(DOCKER_TAG_DEV) \
|
|
|
|
bash
|
2016-11-15 01:01:34 +00:00
|
|
|
|
|
|
|
# Tags dev image so it can be pushed
|
2017-11-21 05:22:44 +00:00
|
|
|
.PHONY: tag
|
2016-11-15 01:01:34 +00:00
|
|
|
tag: build
|
2017-08-29 01:35:05 +00:00
|
|
|
docker tag $(DOCKER_TAG_DEV) $(DOCKER_REPO)/$(DOCKER_TAG)
|
2016-11-15 01:01:34 +00:00
|
|
|
|
|
|
|
# Pushes tagged image to docker hub
|
2017-11-21 05:22:44 +00:00
|
|
|
.PHONY: push
|
2016-11-15 01:01:34 +00:00
|
|
|
push: tag
|
2017-08-29 01:35:05 +00:00
|
|
|
docker push $(DOCKER_REPO)/$(DOCKER_TAG)
|
|
|
|
|
|
|
|
|
|
|
|
# Clears shrinkwrap so next build will install latest version of everything
|
2017-11-21 05:22:44 +00:00
|
|
|
.PHONY: unshrinkwrap
|
2017-08-29 01:35:05 +00:00
|
|
|
unshrinkwrap:
|
|
|
|
rm ./npm-shrinkwrap.json
|
|
|
|
touch ./npm-shrinkwrap.json
|
|
|
|
|
|
|
|
# Generates a new shrinkwrap from installed node modules
|
2017-11-21 05:22:44 +00:00
|
|
|
.PHONY: shrinkwrap
|
2017-08-29 01:35:05 +00:00
|
|
|
shrinkwrap: build
|
|
|
|
docker run --rm \
|
|
|
|
-v "$(shell pwd)/npm-shrinkwrap.json:/homebridge/npm-shrinkwrap-volume.json" \
|
2017-11-21 05:22:44 +00:00
|
|
|
$(shell grep -q '^RUN.*cross-build-start' Dockerfile && echo '-v "/usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static"') \
|
2017-08-29 01:35:05 +00:00
|
|
|
$(DOCKER_TAG_DEV) \
|
|
|
|
bash -c "npm shrinkwrap && cat npm-shrinkwrap.json > npm-shrinkwrap-volume.json"
|
2017-11-21 05:22:44 +00:00
|
|
|
|
|
|
|
# Converts Dockerfile so that it can compile on ARM
|
|
|
|
.PHONY: arm
|
|
|
|
arm:
|
|
|
|
cat Dockerfile | sed '/^RUN.*cross-build-/s/^/# /' > Dockerfile.arm
|
|
|
|
mv Dockerfile.arm Dockerfile
|