2014-07-03 15:29:49 +00:00
|
|
|
DISABLE_CACHE = 'false'
|
|
|
|
|
2014-10-17 11:53:04 +00:00
|
|
|
RPI_IMAGE = resin/rpi-supervisor
|
|
|
|
|
|
|
|
ARCH = rpi# rpi/x86_64/i386
|
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
|
|
|
|
|
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-02 17:34:42 +00:00
|
|
|
docker run --name build-supervisor-base $(BUILDSTEP_REPO):$(BUILDSTEP_VERSION) bash -c "apt-get -q update && apt-get install -qqy openvpn 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
|
|
|
|
docker tag 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
|
|
|
|
|
|
|
supervisor: supervisor-base
|
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
|
|
|
|
2014-10-07 17:41:49 +00:00
|
|
|
supervisor-accelerated: supervisor-base
|
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"
|
2014-10-17 11:53:04 +00:00
|
|
|
docker commit build-supervisor-latest $(RPI_IMAGE):$(SUPERVISOR_VERSION) > /dev/null
|
2014-10-17 11:23:20 +00:00
|
|
|
-docker rm build-supervisor-latest 2> /dev/null
|
2014-07-10 19:54:29 +00:00
|
|
|
|
2014-09-22 12:45:15 +00:00
|
|
|
run-supervisor-x86_64:
|
|
|
|
docker run --privileged -d -v /var/run/docker.sock:/run/docker.sock -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-08-05 14:18:19 +00:00
|
|
|
|
2014-09-22 12:45:15 +00:00
|
|
|
run-supervisor-i386:
|
|
|
|
docker run --privileged -d -v /var/run/docker.sock:/run/docker.sock -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-10-17 12:23:58 +00:00
|
|
|
.PHONY: supervisor supervisor-accelerated run-supervisor-x86_64 run-supervisor-i386
|