diff --git a/Dockerfile.alpine.amd64 b/Dockerfile.alpine.amd64 new file mode 100644 index 00000000..2f90883a --- /dev/null +++ b/Dockerfile.alpine.amd64 @@ -0,0 +1,39 @@ +FROM resin/amd64-alpine-node:0.10.44-slim + +# Supervisor apt dependencies +RUN apk add --update \ + btrfs-progs \ + ca-certificates \ + rsync \ + supervisor \ + && rm -rf /var/cache/apk/* + +# Copy supervisord configuration files +COPY config/supervisor/ /etc/supervisor/ + +# Install dependencies +WORKDIR /app +COPY package.json postinstall.sh /app/ +RUN set -x \ + && buildDeps='g++ sqlite-dev sqlite-libs make' \ + && apk add --update $buildDeps \ + && JOBS=MAX npm install --unsafe-perm --production --no-optional --build-from-source \ + && npm dedupe \ + && npm cache clean \ + && rm -rf /tmp/* \ + && apk del $buildDeps \ + && rm -rf /var/cache/apk/* + +# Copy source +COPY . /app/ + +RUN /app/node_modules/.bin/coffee -c /app/src \ + && ln -sf /app/entry.alpine.sh /start # Needed for legacy + +RUN chmod +x /app/bin/gosuper + +ENV SUPERVISOR_IMAGE resin/amd64-alpine-supervisor +ENV CONFIG_MOUNT_POINT /boot/config.json +ENV LED_FILE /dev/null + +ENTRYPOINT ["/app/entry.alpine.sh"] diff --git a/Dockerfile.alpine.armv7hf b/Dockerfile.alpine.armv7hf new file mode 100644 index 00000000..f70f5809 --- /dev/null +++ b/Dockerfile.alpine.armv7hf @@ -0,0 +1,39 @@ +FROM resin/armhf-alpine-node:0.10.44-slim + +# Supervisor apt dependencies +RUN apk add --update \ + btrfs-progs \ + ca-certificates \ + rsync \ + supervisor \ + && rm -rf /var/cache/apk/* + +# Copy supervisord configuration files +COPY config/supervisor/ /etc/supervisor/ + +# Install dependencies +WORKDIR /app +COPY package.json postinstall.sh /app/ +RUN set -x \ + && buildDeps='g++ sqlite-dev sqlite-libs make' \ + && apk add --update $buildDeps \ + && JOBS=MAX npm install --unsafe-perm --production --no-optional --build-from-source \ + && npm dedupe \ + && npm cache clean \ + && rm -rf /tmp/* \ + && apk del $buildDeps \ + && rm -rf /var/cache/apk/* + +# Copy source +COPY . /app/ + +RUN /app/node_modules/.bin/coffee -c /app/src \ + && ln -sf /app/entry.alpine.sh /start # Needed for legacy + +RUN chmod +x /app/bin/gosuper + +ENV SUPERVISOR_IMAGE resin/armhf-alpine-supervisor +ENV CONFIG_MOUNT_POINT /boot/config.json +ENV LED_FILE /dev/null + +ENTRYPOINT ["/app/entry.alpine.sh"] diff --git a/Dockerfile.alpine.i386 b/Dockerfile.alpine.i386 new file mode 100644 index 00000000..54b5e378 --- /dev/null +++ b/Dockerfile.alpine.i386 @@ -0,0 +1,39 @@ +FROM resin/i386-alpine-node:0.10.44-slim + +# Supervisor apt dependencies +RUN apk add --update \ + btrfs-progs \ + ca-certificates \ + rsync \ + supervisor \ + && rm -rf /var/cache/apk/* + +# Copy supervisord configuration files +COPY config/supervisor/ /etc/supervisor/ + +# Install dependencies +WORKDIR /app +COPY package.json postinstall.sh /app/ +RUN set -x \ + && buildDeps='g++ sqlite-dev sqlite-libs make' \ + && apk add --update $buildDeps \ + && JOBS=MAX npm install --unsafe-perm --production --no-optional --build-from-source \ + && npm dedupe \ + && npm cache clean \ + && rm -rf /tmp/* \ + && apk del $buildDeps \ + && rm -rf /var/cache/apk/* + +# Copy source +COPY . /app/ + +RUN /app/node_modules/.bin/coffee -c /app/src \ + && ln -sf /app/entry.alpine.sh /start # Needed for legacy + +RUN chmod +x /app/bin/gosuper + +ENV SUPERVISOR_IMAGE resin/i386-alpine-supervisor +ENV CONFIG_MOUNT_POINT /boot/config.json +ENV LED_FILE /dev/null + +ENTRYPOINT ["/app/entry.alpine.sh"] diff --git a/Dockerfile.alpine.rpi b/Dockerfile.alpine.rpi new file mode 100644 index 00000000..f70f5809 --- /dev/null +++ b/Dockerfile.alpine.rpi @@ -0,0 +1,39 @@ +FROM resin/armhf-alpine-node:0.10.44-slim + +# Supervisor apt dependencies +RUN apk add --update \ + btrfs-progs \ + ca-certificates \ + rsync \ + supervisor \ + && rm -rf /var/cache/apk/* + +# Copy supervisord configuration files +COPY config/supervisor/ /etc/supervisor/ + +# Install dependencies +WORKDIR /app +COPY package.json postinstall.sh /app/ +RUN set -x \ + && buildDeps='g++ sqlite-dev sqlite-libs make' \ + && apk add --update $buildDeps \ + && JOBS=MAX npm install --unsafe-perm --production --no-optional --build-from-source \ + && npm dedupe \ + && npm cache clean \ + && rm -rf /tmp/* \ + && apk del $buildDeps \ + && rm -rf /var/cache/apk/* + +# Copy source +COPY . /app/ + +RUN /app/node_modules/.bin/coffee -c /app/src \ + && ln -sf /app/entry.alpine.sh /start # Needed for legacy + +RUN chmod +x /app/bin/gosuper + +ENV SUPERVISOR_IMAGE resin/armhf-alpine-supervisor +ENV CONFIG_MOUNT_POINT /boot/config.json +ENV LED_FILE /dev/null + +ENTRYPOINT ["/app/entry.alpine.sh"] diff --git a/Makefile b/Makefile index c9c644b4..baa771e4 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ DISABLE_CACHE = 'false' ARCH = rpi# rpi/amd64/i386/armv7hf/armel +BASE_DISTRO = DEPLOY_REGISTRY = @@ -9,13 +10,22 @@ JOB_NAME = 1 all: supervisor -IMAGE = "resin/$(ARCH)-supervisor:$(SUPERVISOR_VERSION)" -SUPERVISOR_IMAGE=$(DEPLOY_REGISTRY)$(IMAGE) - PUBNUB_SUBSCRIBE_KEY = sub-c-bananas PUBNUB_PUBLISH_KEY = pub-c-bananas MIXPANEL_TOKEN = bananasbananas +ifdef BASE_DISTRO +$(info BASE_DISTRO SPECIFIED. START BUILDING ALPINE SUPERVISOR) + IMAGE = "resin/$(ARCH)-supervisor:$(SUPERVISOR_VERSION)-alpine" + DOCKERFILE = alpine.$(ARCH) +else +$(info BASE_DISTRO NOT SPECIFIED. START BUILDING DEBIAN SUPERVISOR) + IMAGE = "resin/$(ARCH)-supervisor:$(SUPERVISOR_VERSION)" + DOCKERFILE = $(ARCH) +endif + +SUPERVISOR_IMAGE=$(DEPLOY_REGISTRY)$(IMAGE) + ifeq ($(ARCH),rpi) GOARCH = arm GOARM = 6 @@ -60,7 +70,7 @@ stop-supervisor: -docker rm -f --volumes resin_supervisor_1 > /dev/null || true supervisor: gosuper - cp Dockerfile.$(ARCH) Dockerfile + cp Dockerfile.$(DOCKERFILE) Dockerfile echo "ENV VERSION "`jq -r .version package.json` >> Dockerfile echo "ENV DEFAULT_PUBNUB_PUBLISH_KEY $(PUBNUB_PUBLISH_KEY)" >> Dockerfile echo "ENV DEFAULT_PUBNUB_SUBSCRIBE_KEY $(PUBNUB_SUBSCRIBE_KEY)" >> Dockerfile diff --git a/automation/jenkins_build.sh b/automation/jenkins_build.sh index 3b2b00e8..fbc5e2f5 100755 --- a/automation/jenkins_build.sh +++ b/automation/jenkins_build.sh @@ -11,36 +11,29 @@ docker pull resin/${ARCH}-supervisor:${ESCAPED_BRANCH_NAME} || docker pull resin # Test the gosuper make SUPERVISOR_VERSION=${VERSION} JOB_NAME=${JOB_NAME} test-gosuper -# Build the images -make SUPERVISOR_VERSION=${ESCAPED_BRANCH_NAME} \ - ARCH=${ARCH} \ - JOB_NAME=${JOB_NAME} \ - DEPLOY_REGISTRY= \ - PUBNUB_SUBSCRIBE_KEY=${PUBNUB_SUBSCRIBE_KEY} \ - PUBNUB_PUBLISH_KEY=${PUBNUB_PUBLISH_KEY} \ - MIXPANEL_TOKEN=${MIXPANEL_TOKEN} \ - deploy -make SUPERVISOR_VERSION=${VERSION} \ - ARCH=${ARCH} \ - JOB_NAME=${JOB_NAME} \ - DEPLOY_REGISTRY= \ - PUBNUB_SUBSCRIBE_KEY=${PUBNUB_SUBSCRIBE_KEY} \ - PUBNUB_PUBLISH_KEY=${PUBNUB_PUBLISH_KEY} \ - MIXPANEL_TOKEN=${MIXPANEL_TOKEN} \ - deploy -make SUPERVISOR_VERSION=${ESCAPED_BRANCH_NAME} \ - ARCH=${ARCH} \ - JOB_NAME=${JOB_NAME} \ - DEPLOY_REGISTRY=registry.resinstaging.io/ \ - PUBNUB_SUBSCRIBE_KEY=${PUBNUB_SUBSCRIBE_KEY} \ - PUBNUB_PUBLISH_KEY=${PUBNUB_PUBLISH_KEY} \ - MIXPANEL_TOKEN=${MIXPANEL_TOKEN} \ - deploy -make SUPERVISOR_VERSION=${VERSION} \ - ARCH=${ARCH} \ - JOB_NAME=${JOB_NAME} \ - DEPLOY_REGISTRY=registry.resinstaging.io/ \ - PUBNUB_SUBSCRIBE_KEY=${PUBNUB_SUBSCRIBE_KEY} \ - PUBNUB_PUBLISH_KEY=${PUBNUB_PUBLISH_KEY} \ - MIXPANEL_TOKEN=${MIXPANEL_TOKEN} \ - deploy +MAKE_ARGS="ARCH=${ARCH} \ + JOB_NAME=${JOB_NAME} \ + BASE_DISTRO=${BASE_DISTRO} \ + PUBNUB_SUBSCRIBE_KEY=${PUBNUB_SUBSCRIBE_KEY} \ + PUBNUB_PUBLISH_KEY=${PUBNUB_PUBLISH_KEY} \ + MIXPANEL_TOKEN=${MIXPANEL_TOKEN}" + +make ${MAKE_ARGS} \ + SUPERVISOR_VERSION=${ESCAPED_BRANCH_NAME} \ + DEPLOY_REGISTRY= \ + deploy + +make ${MAKE_ARGS} \ + SUPERVISOR_VERSION=${VERSION} \ + DEPLOY_REGISTRY= \ + deploy + +make ${MAKE_ARGS} \ + SUPERVISOR_VERSION=${ESCAPED_BRANCH_NAME} \ + DEPLOY_REGISTRY=registry.resinstaging.io/ \ + deploy + +make ${MAKE_ARGS} \ + SUPERVISOR_VERSION=${VERSION} \ + DEPLOY_REGISTRY=registry.resinstaging.io/ \ + deploy diff --git a/entry.alpine.sh b/entry.alpine.sh new file mode 100755 index 00000000..a8da303b --- /dev/null +++ b/entry.alpine.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +set -e + +[ -d /dev/net ] || + mkdir -p /dev/net +[ -c /dev/net/tun ] || + mknod /dev/net/tun c 10 200 + +mkdir -p /var/log/supervisor && touch /var/log/supervisor/supervisord.log +mkdir -p /var/run/resin +mount -t tmpfs -o size=1m tmpfs /var/run/resin + +if [ -z "$GOSUPER_SOCKET" ]; then + export GOSUPER_SOCKET=/var/run/resin/gosuper.sock +fi +if [ -z "$DOCKER_SOCKET" ]; then + export DOCKER_SOCKET=/run/docker.sock +fi +if [ -z "$HOST_PROC" ]; then + export HOST_PROC=/mnt/root/proc +fi + +export DBUS_SYSTEM_BUS_ADDRESS="unix:path=/mnt/root/run/dbus/system_bus_socket" + +/usr/bin/supervisord -c /etc/supervisor/supervisord.conf + +supervisorctl -c /etc/supervisor/supervisord.conf start resin-supervisor +supervisorctl -c /etc/supervisor/supervisord.conf start go-supervisor + +tail -f /var/log/supervisor/supervisord.log diff --git a/package.json b/package.json index 7b0406ba..3800000a 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "resin-register-device": "^2.0.0", "request-progress": "^0.3.1", "rwlock": "^5.0.0", - "sqlite3": "~3.0.4", + "sqlite3": "3.0.9", "typed-error": "~0.1.0" }, "engines": {