2014-07-03 15:29:49 +00:00
|
|
|
DISABLE_CACHE = 'false'
|
|
|
|
|
2014-10-17 11:53:04 +00:00
|
|
|
ARCH = rpi# rpi/x86_64/i386
|
2014-07-03 15:29:49 +00:00
|
|
|
|
2015-02-11 17:21:10 +00:00
|
|
|
DEPLOY_REGISTRY = registry.resindev.io:5000
|
|
|
|
|
2014-07-03 15:29:49 +00:00
|
|
|
SUPERVISOR_VERSION = latest
|
|
|
|
|
2014-10-17 11:23:20 +00:00
|
|
|
BUILDSTEP_VERSION = master
|
2014-07-03 15:29:49 +00:00
|
|
|
|
2014-07-10 13:57:57 +00:00
|
|
|
BUILDSTEP_REPO = resin/rpi-buildstep-armv6hf
|
|
|
|
|
2014-08-01 14:10:42 +00:00
|
|
|
# This allows using a cache for building the supervisor, making it much faster.
|
2014-10-22 17:27:41 +00:00
|
|
|
CACHE_VOLUME = ~/cache/resin-supervisor
|
2014-08-01 14:10:42 +00:00
|
|
|
|
2014-07-03 15:29:49 +00:00
|
|
|
all: supervisor
|
|
|
|
|
2015-02-03 17:10:37 +00:00
|
|
|
IMAGE = "resin/$(ARCH)-supervisor:$(SUPERVISOR_VERSION)"
|
2014-10-07 17:43:30 +00:00
|
|
|
VERSIONED_IMAGES = "$(shell docker images --all | grep $(BUILDSTEP_VERSION) | awk '{print $$1}')"
|
2014-10-17 11:23:20 +00:00
|
|
|
BUILDSTEP_PRESENT = $(shell echo $(VERSIONED_IMAGES) | grep --extended-regexp '$(BUILDSTEP_REPO)(\s|$$)' )
|
2014-10-07 17:43:30 +00:00
|
|
|
SUPERVISOR_BASE_PRESENT = $(shell echo $(VERSIONED_IMAGES) | grep --extended-regexp 'resin/supervisor-base(\s|$$)' )
|
2014-10-17 11:23:20 +00:00
|
|
|
ACCELERATOR = $(shell docker ps --all | grep buildstep-accelerator-$(BUILDSTEP_VERSION) | awk '{print $$1}' )
|
|
|
|
|
|
|
|
clean:
|
2014-10-17 12:41:27 +00:00
|
|
|
ifeq "$(ARCH)" "rpi"
|
2014-10-17 11:53:04 +00:00
|
|
|
-docker rm -f build-supervisor-base 2> /dev/null
|
2014-10-17 11:23:20 +00:00
|
|
|
-docker rmi resin/supervisor-base:latest
|
|
|
|
-docker rmi resin/supervisor-base:$(BUILDSTEP_VERSION)
|
|
|
|
-docker rm buildstep-accelerator-$(BUILDSTEP_VERSION) 2> /dev/null
|
2014-10-22 17:27:41 +00:00
|
|
|
-rm -rf $(CACHE_VOLUME)
|
2014-10-17 12:41:27 +00:00
|
|
|
@echo "Older images cleaned."
|
|
|
|
endif
|
2014-07-10 19:54:29 +00:00
|
|
|
|
2014-10-07 17:41:49 +00:00
|
|
|
supervisor-base:
|
2014-10-17 11:53:04 +00:00
|
|
|
ifeq "$(ARCH)" "rpi"
|
2014-10-07 17:43:30 +00:00
|
|
|
ifneq ($(SUPERVISOR_BASE_PRESENT) , )
|
|
|
|
@echo "Using existing supervisor base from resin/supervisor-base:$(BUILDSTEP_VERSION)"
|
|
|
|
else
|
2014-10-17 12:41:27 +00:00
|
|
|
docker pull $(BUILDSTEP_REPO):$(BUILDSTEP_VERSION)
|
2014-10-17 12:29:27 +00:00
|
|
|
-docker rm -f build-supervisor-base 2> /dev/null
|
2015-01-12 15:15:03 +00:00
|
|
|
docker run --name build-supervisor-base $(BUILDSTEP_REPO):$(BUILDSTEP_VERSION) bash -c "apt-get -q update && apt-get install -qqy libsqlite3-dev socat supervisor && apt-get clean && rm -rf /var/lib/apt/lists/"
|
2014-10-07 17:43:30 +00:00
|
|
|
docker commit build-supervisor-base resin/supervisor-base:$(BUILDSTEP_VERSION)
|
2014-10-17 11:23:20 +00:00
|
|
|
-docker rm build-supervisor-base 2> /dev/null
|
2014-10-07 17:43:30 +00:00
|
|
|
endif
|
2015-01-12 15:25:48 +00:00
|
|
|
docker tag -f resin/supervisor-base:$(BUILDSTEP_VERSION) resin/supervisor-base:latest
|
2014-10-17 11:53:04 +00:00
|
|
|
endif
|
2014-10-07 17:41:49 +00:00
|
|
|
|
2015-01-27 13:04:34 +00:00
|
|
|
supervisor:
|
2014-10-17 12:21:47 +00:00
|
|
|
cp Dockerfile.$(ARCH) Dockerfile
|
|
|
|
echo "ENV VERSION "`jq -r .version package.json` >> Dockerfile
|
|
|
|
docker build --no-cache=$(DISABLE_CACHE) -t resin/$(ARCH)-supervisor:$(SUPERVISOR_VERSION) .
|
|
|
|
rm Dockerfile
|
2014-07-03 15:29:49 +00:00
|
|
|
|
2015-02-11 17:21:10 +00:00
|
|
|
deploy: supervisor
|
|
|
|
docker tag -f $(IMAGE) $(DEPLOY_REGISTRY)/$(IMAGE)
|
|
|
|
docker push $(DEPLOY_REGISTRY)/$(IMAGE)
|
|
|
|
|
2014-10-07 17:41:49 +00:00
|
|
|
supervisor-accelerated: supervisor-base
|
2015-02-03 17:10:37 +00:00
|
|
|
ifneq "$(ARCH)" "rpi"
|
|
|
|
@echo 'Can only accelerate an rpi build.'
|
|
|
|
else
|
2014-10-17 11:23:20 +00:00
|
|
|
ifeq ($(ACCELERATOR) , )
|
|
|
|
@echo 'Supervisor accelerator not found - Downloading resin/buildstep-accelerator and preparing.'
|
2014-10-17 12:41:27 +00:00
|
|
|
docker pull resin/rpi-buildstep-accelerator:$(BUILDSTEP_VERSION)
|
2014-10-17 11:23:20 +00:00
|
|
|
-docker rm buildstep-accelerator-$(BUILDSTEP_VERSION) 2> /dev/null
|
|
|
|
docker run --name=buildstep-accelerator-$(BUILDSTEP_VERSION) -v /.a resin/rpi-buildstep-accelerator:$(BUILDSTEP_VERSION) /prepare-accelerator.sh
|
|
|
|
endif
|
2014-10-17 12:29:27 +00:00
|
|
|
-docker rm -f build-supervisor-latest 2> /dev/null
|
2014-10-22 17:27:41 +00:00
|
|
|
docker run --name build-supervisor-latest --volume $(CACHE_VOLUME):/cache --volumes-from `docker ps --all | grep buildstep-accelerator-$(BUILDSTEP_VERSION) | awk '{print $$1}'`:ro --env VERSION=`jq -r .version package.json` -v `pwd`:/tmp/app resin/supervisor-base:latest bash -i -c ". /.env && cp -r /tmp/app /app && /build/builder"
|
2015-02-03 17:10:37 +00:00
|
|
|
docker commit build-supervisor-latest $(IMAGE) > /dev/null
|
2014-10-17 11:23:20 +00:00
|
|
|
-docker rm build-supervisor-latest 2> /dev/null
|
2015-02-03 17:10:37 +00:00
|
|
|
endif
|
2014-07-10 19:54:29 +00:00
|
|
|
|
2015-02-11 17:21:10 +00:00
|
|
|
deploy-accelerated: supervisor-accelerated
|
|
|
|
docker tag -f $(IMAGE) $(DEPLOY_REGISTRY)/$(IMAGE)
|
|
|
|
docker push $(DEPLOY_REGISTRY)/$(IMAGE)
|
|
|
|
|
2014-09-22 12:45:15 +00:00
|
|
|
run-supervisor-x86_64:
|
2015-01-14 17:00:13 +00:00
|
|
|
docker run --privileged -d -v /var/run/docker.sock:/run/docker.sock -v /boot/config.json:/boot/config.json -v /:/mnt/root -v /resin-data/resin-supervisor:/data -v /proc/net/fib_trie:/mnt/fib_trie -v /var/log/supervisor-log:/var/log -e API_ENDPOINT=https://staging.resin.io -e REGISTRY_ENDPOINT=registry.staging.resin.io -e PUBNUB_SUBSCRIBE_KEY=sub-c-bananas -e PUBNUB_PUBLISH_KEY=pub-c-bananas -e MIXPANEL_TOKEN=bananasbananas resin/x86_64-supervisor /start
|
2014-09-22 12:45:15 +00:00
|
|
|
run-supervisor-i386:
|
2015-01-14 17:00:13 +00:00
|
|
|
docker run --privileged -d -v /var/run/docker.sock:/run/docker.sock -v /boot/config.json:/boot/config.json -v /:/mnt/root -v /resin-data/resin-supervisor:/data -v /proc/net/fib_trie:/mnt/fib_trie -v /var/log/supervisor-log:/var/log -e API_ENDPOINT=https://staging.resin.io -e REGISTRY_ENDPOINT=registry.staging.resin.io -e PUBNUB_SUBSCRIBE_KEY=sub-c-bananas -e PUBNUB_PUBLISH_KEY=pub-c-bananas -e MIXPANEL_TOKEN=bananasbananas resin/i386-supervisor /start
|
2014-09-22 12:45:15 +00:00
|
|
|
|
2015-02-11 17:21:10 +00:00
|
|
|
.PHONY: supervisor supervisor-accelerated deploy deploy-accelerated run-supervisor-x86_64 run-supervisor-i386
|