Merge pull request #223 from resin-io/rockerfile-based-build

oe-images build system integration
This commit is contained in:
Petros Angelatos 2016-09-14 16:01:53 -07:00 committed by GitHub
commit 1740cf615c
29 changed files with 241 additions and 712 deletions

View File

@ -9,5 +9,5 @@ coffeelint.json
automation
tools
README.md
gosuper
retry_docker_push.sh
base-image

6
.gitignore vendored
View File

@ -12,3 +12,9 @@ base-image/build/cache
base-image/build/downloads
base-image/build/sstate-cache
base-image/build/tmp-glibc
Dockerfile.build.*
Dockerfile.runtime.*
!Dockerfile.build.template
!Dockerfile.runtime.template
build

View File

@ -1,9 +0,0 @@
path-exclude /usr/share/doc/*
path-exclude /usr/share/man/*
path-exclude /usr/share/groff/*
path-exclude /usr/share/info/*
path-exclude /usr/share/lintian/*
path-exclude /usr/share/linda/*
path-exclude /usr/share/locale/*
path-include /usr/share/locale/en*

View File

@ -1,3 +1,9 @@
* Compress go binary with upx [petrosagg]
* Switch to go version 1.6 [petrosagg]
* Print all logs to stdout of container instead of file [petrosagg]
* Upgrade nodejs to version 6.5 [petrosagg]
* Switch initsystem from supervisor to busybox init [petrosagg]
* Switch build to openembedded base images [petrosagg]
* DRY up calls to gosuper API, and use empty Host header [Pablo]
# v2.1.1

View File

@ -1,51 +0,0 @@
FROM resin/amd64-alpine-node:0.10.44-slim
ENV DOCKER_COMPOSE_VERSION 1.7.1
ENV DOCKER_COMPOSE_SHA256 0b8184817097eb670b92cbdac6cb9f7f2e9fe384c0b1060cb9b3d1a475fcbea6
# Supervisor apt dependencies
RUN apk add --update \
btrfs-progs \
ca-certificates \
curl \
rsync \
supervisor \
&& curl -sLO http://resin-packages.s3.amazonaws.com/docker-compose/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-alpine-amd64-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& echo "$DOCKER_COMPOSE_SHA256 docker-compose-linux-alpine-amd64-${DOCKER_COMPOSE_VERSION}.tar.gz" > docker-compose-linux-alpine-amd64-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& sha256sum -c docker-compose-linux-alpine-amd64-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& tar xzf docker-compose-linux-alpine-amd64-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& mv docker-compose-linux-alpine-amd64-${DOCKER_COMPOSE_VERSION}/docker-compose-linux-alpine-amd64 /usr/bin/docker-compose \
&& rm -rf docker-compose-linux-alpine-amd64-${DOCKER_COMPOSE_VERSION}* \
&& apk del curl \
&& 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-supervisor
ENV SUPERVISOR_TAG_EXTRA alpine
ENV CONFIG_MOUNT_POINT /boot/config.json
ENV LED_FILE /dev/null
ENTRYPOINT ["/app/entry.alpine.sh"]

View File

@ -1,51 +0,0 @@
FROM resin/armhf-alpine-node:0.10.44-slim
ENV DOCKER_COMPOSE_VERSION 1.7.1
ENV DOCKER_COMPOSE_SHA256 3e5d0a36f06d9f7a93eb20c1dee67da623b07a322168538ea80d65c8581f5567
# Supervisor apt dependencies
RUN apk add --update \
btrfs-progs \
ca-certificates \
curl \
rsync \
supervisor \
&& curl -sLO http://resin-packages.s3.amazonaws.com/docker-compose/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& echo "$DOCKER_COMPOSE_SHA256 docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz" > docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& sha256sum -c docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& tar xzf docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& mv docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}/docker-compose-linux-alpine-armhf /usr/bin/docker-compose \
&& rm -rf docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}* \
&& apk del curl \
&& 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/armv7hf-supervisor
ENV SUPERVISOR_TAG_EXTRA alpine
ENV CONFIG_MOUNT_POINT /boot/config.json
ENV LED_FILE /dev/null
ENTRYPOINT ["/app/entry.alpine.sh"]

View File

@ -1,51 +0,0 @@
FROM resin/i386-alpine-node:0.10.44-slim
ENV DOCKER_COMPOSE_VERSION 1.7.1
ENV DOCKER_COMPOSE_SHA256 160ba547bfd4dc967ec4f1927550f2d832316fad492e0e6f8d374da89ddac779
# Supervisor apt dependencies
RUN apk add --update \
btrfs-progs \
ca-certificates \
curl \
rsync \
supervisor \
&& curl -sLO http://resin-packages.s3.amazonaws.com/docker-compose/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-alpine-i386-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& echo "$DOCKER_COMPOSE_SHA256 docker-compose-linux-alpine-i386-${DOCKER_COMPOSE_VERSION}.tar.gz" > docker-compose-linux-alpine-i386-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& sha256sum -c docker-compose-linux-alpine-i386-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& tar xzf docker-compose-linux-alpine-i386-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& mv docker-compose-linux-alpine-i386-${DOCKER_COMPOSE_VERSION}/docker-compose-linux-alpine-i386 /usr/bin/docker-compose \
&& rm -rf docker-compose-linux-alpine-i386-${DOCKER_COMPOSE_VERSION}* \
&& apk del curl \
&& 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-supervisor
ENV SUPERVISOR_TAG_EXTRA alpine
ENV CONFIG_MOUNT_POINT /boot/config.json
ENV LED_FILE /dev/null
ENTRYPOINT ["/app/entry.alpine.sh"]

View File

@ -1,51 +0,0 @@
FROM resin/armhf-alpine-node:0.10.44-slim
ENV DOCKER_COMPOSE_VERSION 1.7.1
ENV DOCKER_COMPOSE_SHA256 3e5d0a36f06d9f7a93eb20c1dee67da623b07a322168538ea80d65c8581f5567
# Supervisor apt dependencies
RUN apk add --update \
btrfs-progs \
ca-certificates \
curl \
rsync \
supervisor \
&& curl -sLO http://resin-packages.s3.amazonaws.com/docker-compose/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& echo "$DOCKER_COMPOSE_SHA256 docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz" > docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& sha256sum -c docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& tar xzf docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& mv docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}/docker-compose-linux-alpine-armhf /usr/bin/docker-compose \
&& rm -rf docker-compose-linux-alpine-armhf-${DOCKER_COMPOSE_VERSION}* \
&& apk del curl \
&& 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/rpi-supervisor
ENV SUPERVISOR_TAG_EXTRA alpine
ENV CONFIG_MOUNT_POINT /boot/config.json
ENV LED_FILE /dev/null
ENTRYPOINT ["/app/entry.alpine.sh"]

View File

@ -1,57 +0,0 @@
FROM resin/amd64-node:0.10.40-slim
COPY 01_nodoc /etc/dpkg/dpkg.cfg.d/
ENV DOCKER_COMPOSE_VERSION 1.7.1
ENV DOCKER_COMPOSE_SHA256 37df85ee18bf0e2a8d71cbfb8198b1c06cc388f19118be7bdfc4d6db112af834
# Supervisor apt dependencies
RUN apt-get -q update \
&& apt-get install -qqy \
btrfs-tools \
ca-certificates \
curl \
iptables \
rsync \
supervisor \
--no-install-recommends \
&& curl -sLO http://resin-packages.s3.amazonaws.com/docker-compose/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-amd64-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& echo $DOCKER_COMPOSE_SHA256 docker-compose-linux-amd64-${DOCKER_COMPOSE_VERSION}.tar.gz > docker-compose-linux-amd64-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& sha256sum -c docker-compose-linux-amd64-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& tar xzf docker-compose-linux-amd64-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& mv docker-compose-linux-amd64-${DOCKER_COMPOSE_VERSION}/docker-compose-linux-amd64 /usr/bin/docker-compose \
&& rm -rf docker-compose-linux-amd64-${DOCKER_COMPOSE_VERSION}* \
&& apt-get purge -qqy curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/
# Copy supervisord configuration files
COPY config/supervisor/ /etc/supervisor/
# Install dependencies
WORKDIR /app
COPY package.json postinstall.sh /app/
RUN apt-get -q update \
&& apt-get install -qqy g++ libsqlite3-dev make --no-install-recommends \
&& JOBS=MAX npm install --unsafe-perm --production --no-optional \
&& npm dedupe \
&& npm cache clean \
&& rm -rf /tmp/* \
&& apt-get purge -qqy g++ libsqlite3-dev make binutils \
&& apt-get clean \
&& apt-get autoremove -qqy \
&& rm -rf /var/lib/apt/lists/
# Copy source
COPY . /app/
RUN /app/node_modules/.bin/coffee -c /app/src \
&& ln -sf /app/entry.sh /start # Needed for legacy
RUN chmod +x /app/bin/gosuper
ENV SUPERVISOR_IMAGE resin/amd64-supervisor
ENV CONFIG_MOUNT_POINT /boot/config.json
ENV LED_FILE /dev/null
ENTRYPOINT ["/app/entry.sh"]

View File

@ -1,57 +0,0 @@
FROM resin/armel-node:0.10.40-slim
COPY 01_nodoc /etc/dpkg/dpkg.cfg.d/
ENV DOCKER_COMPOSE_VERSION 1.7.1
ENV DOCKER_COMPOSE_SHA256 a1025fed97536e2698798ea277a014ec5e1eae816a8cf3155ecbe9679e3e7bac
# Supervisor apt dependencies
RUN apt-get -q update \
&& apt-get install -qqy \
btrfs-tools \
ca-certificates \
curl \
iptables \
rsync \
supervisor \
--no-install-recommends \
&& curl -sLO http://resin-packages.s3.amazonaws.com/docker-compose/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-armel-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& echo $DOCKER_COMPOSE_SHA256 docker-compose-linux-armel-${DOCKER_COMPOSE_VERSION}.tar.gz > docker-compose-linux-armel-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& sha256sum -c docker-compose-linux-armel-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& tar xzf docker-compose-linux-armel-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& mv docker-compose-linux-armel-${DOCKER_COMPOSE_VERSION}/docker-compose-linux-armel /usr/bin/docker-compose \
&& rm -rf docker-compose-linux-armel-${DOCKER_COMPOSE_VERSION}* \
&& apt-get purge -qqy curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/
# Copy supervisord configuration files
COPY config/supervisor/ /etc/supervisor/
# Install dependencies
WORKDIR /app
COPY package.json postinstall.sh /app/
RUN apt-get -q update \
&& apt-get install -qqy g++ libsqlite3-dev make --no-install-recommends \
&& JOBS=MAX npm install --unsafe-perm --production --no-optional \
&& npm dedupe \
&& npm cache clean \
&& rm -rf /tmp/* \
&& apt-get purge -qqy g++ libsqlite3-dev make binutils \
&& apt-get clean \
&& apt-get autoremove -qqy \
&& rm -rf /var/lib/apt/lists/
# Copy source
COPY . /app/
RUN /app/node_modules/.bin/coffee -c /app/src \
&& ln -sf /app/entry.sh /start # Needed for legacy
RUN chmod +x /app/bin/gosuper
ENV SUPERVISOR_IMAGE resin/armel-supervisor
ENV CONFIG_MOUNT_POINT /boot/config.json
ENV LED_FILE /dev/null
ENTRYPOINT ["/app/entry.sh"]

View File

@ -1,57 +0,0 @@
FROM resin/armv7hf-node:0.10.40-slim
COPY 01_nodoc /etc/dpkg/dpkg.cfg.d/
ENV DOCKER_COMPOSE_VERSION 1.7.1
ENV DOCKER_COMPOSE_SHA256 3f0b8c69c66a2daa5fbb0c127cb76ca95d7125827a9c43dd3c36f9bc2ed6e0e5
# Supervisor apt dependencies
RUN apt-get -q update \
&& apt-get install -qqy \
btrfs-tools \
ca-certificates \
curl \
iptables \
rsync \
supervisor \
--no-install-recommends \
&& curl -sLO http://resin-packages.s3.amazonaws.com/docker-compose/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& echo $DOCKER_COMPOSE_SHA256 docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz > docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& sha256sum -c docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& tar xzf docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& mv docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}/docker-compose-linux-armhf /usr/bin/docker-compose \
&& rm -rf docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}* \
&& apt-get purge -qqy curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/
# Copy supervisord configuration files
COPY config/supervisor/ /etc/supervisor/
# Install dependencies
WORKDIR /app
COPY package.json postinstall.sh /app/
RUN apt-get -q update \
&& apt-get install -qqy g++ libsqlite3-dev make --no-install-recommends \
&& JOBS=MAX npm install --unsafe-perm --production --no-optional \
&& npm dedupe \
&& npm cache clean \
&& rm -rf /tmp/* \
&& apt-get purge -qqy g++ libsqlite3-dev make binutils \
&& apt-get clean \
&& apt-get autoremove -qqy \
&& rm -rf /var/lib/apt/lists/
# Copy source
COPY . /app/
RUN /app/node_modules/.bin/coffee -c /app/src \
&& ln -sf /app/entry.sh /start # Needed for legacy
RUN chmod +x /app/bin/gosuper
ENV SUPERVISOR_IMAGE resin/armv7hf-supervisor
ENV CONFIG_MOUNT_POINT /boot/config.json
ENV LED_FILE /dev/null
ENTRYPOINT ["/app/entry.sh"]

78
Dockerfile.build.template Normal file
View File

@ -0,0 +1,78 @@
# Build nodejs dependencies
# The node version here should match the version of the runtime image which is
# specified in the base-image subdirectory in the project
FROM resin/%%ARCH%%-node:6.5-slim
WORKDIR /usr/src/app
RUN apt-get update \
&& apt-get install -y \
g++ \
libsqlite3-dev \
make \
python \
rsync \
wget \
&& rm -rf /var/lib/apt/lists/
ENV DOCKER_COMPOSE_VERSION 1.7.1
ENV DOCKER_COMPOSE_SHA256_amd64 37df85ee18bf0e2a8d71cbfb8198b1c06cc388f19118be7bdfc4d6db112af834
ENV DOCKER_COMPOSE_SHA256_i386 b926fd9a2a9d89358f1353867706f94558a62caaf3aa72bf10bcbbe31e1a44f0
ENV DOCKER_COMPOSE_SHA256_rpi 3f0b8c69c66a2daa5fbb0c127cb76ca95d7125827a9c43dd3c36f9bc2ed6e0e5
ENV DOCKER_COMPOSE_SHA256_armv7hf 3f0b8c69c66a2daa5fbb0c127cb76ca95d7125827a9c43dd3c36f9bc2ed6e0e5
ENV DOCKER_COMPOSE_SHA256_armel a1025fed97536e2698798ea277a014ec5e1eae816a8cf3155ecbe9679e3e7bac
RUN set -x \
&& mkdir -p rootfs-overlay/usr/bin/ \
&& ln -s /lib rootfs-overlay/lib64 \
&& pkgname='docker-compose' \
&& arch=%%ARCH%% \
&& if [ $arch = 'rpi' -o $arch = 'armv7hf' ]; then arch=armhf; fi \
&& base="http://resin-packages.s3.amazonaws.com/${pkgname}" \
&& pkgver=$DOCKER_COMPOSE_VERSION \
&& checksum=$DOCKER_COMPOSE_SHA256_%%ARCH%% \
&& wget "${base}/${pkgver}/${pkgname}-linux-${arch}-${pkgver}.tar.gz" \
&& echo "$checksum ${pkgname}-linux-${arch}-${pkgver}.tar.gz" | sha256sum -c \
&& tar xzf "${pkgname}-linux-${arch}-${pkgver}.tar.gz" --strip-components=1 -C rootfs-overlay/usr/bin \
&& mv "rootfs-overlay/usr/bin/${pkgname}-linux-${arch}" rootfs-overlay/usr/bin/docker-compose
COPY package.json /usr/src/app/
# First install devDependencies too in order to run the build
RUN JOBS=MAX npm install --unsafe-perm
COPY src /usr/src/app/src
RUN npm run lint \
&& npm run build
# Re-install just production modules. This should be fast due to npm cache from previous layer
RUN rm -rf node_modules \
&& JOBS=MAX npm install --unsafe-perm --production --no-optional \
&& npm dedupe
# Remove various uneeded filetypes in order to reduce space
RUN find . -path '*/coverage/*' -o -path '*/test/*' -o -path '*/.nyc_output/*' \
-o -name '*.tar.*' -o -name '*.in' -o -name '*.cc' \
-o -name '*.c' -o -name '*.coffee' -o -name '*.eslintrc' \
-o -name '*.h' -o -name '*.html' -o -name '*.markdown' \
-o -name '*.md' -o -name '*.patch' -o -name '*.png' \
-o -name '*.yml' \
-delete \
&& find . -type f -path '*/node_modules/lodash*' ! -name lodash.js -delete \
&& find . -type f -path '*/node_modules/sqlite3/deps*' -delete \
&& find . -type f -path '*/node_modules/knex/build*' -delete
# Create /var/run/resin for the gosuper to place its socket in
RUN mkdir -p rootfs-overlay/var/run/resin
COPY entry.sh run.sh package.json rootfs-overlay/usr/src/app/
COPY inittab rootfs-overlay/etc/inittab
CMD rsync -a --delete node_modules src rootfs-overlay /build
# -*- mode: dockerfile -*-
# vi: set ft=dockerfile :

View File

@ -1,57 +0,0 @@
FROM resin/i386-node:0.10.40-slim
COPY 01_nodoc /etc/dpkg/dpkg.cfg.d/
ENV DOCKER_COMPOSE_VERSION 1.7.1
ENV DOCKER_COMPOSE_SHA256 b926fd9a2a9d89358f1353867706f94558a62caaf3aa72bf10bcbbe31e1a44f0
# Supervisor apt dependencies
RUN apt-get -q update \
&& apt-get install -qqy \
btrfs-tools \
ca-certificates \
curl \
iptables \
rsync \
supervisor \
--no-install-recommends \
&& curl -sLO http://resin-packages.s3.amazonaws.com/docker-compose/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-i386-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& echo $DOCKER_COMPOSE_SHA256 docker-compose-linux-i386-${DOCKER_COMPOSE_VERSION}.tar.gz > docker-compose-linux-i386-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& sha256sum -c docker-compose-linux-i386-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& tar xzf docker-compose-linux-i386-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& mv docker-compose-linux-i386-${DOCKER_COMPOSE_VERSION}/docker-compose-linux-i386 /usr/bin/docker-compose \
&& rm -rf docker-compose-linux-i386-${DOCKER_COMPOSE_VERSION}* \
&& apt-get purge -qqy curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/
# Copy supervisord configuration files
COPY config/supervisor/ /etc/supervisor/
# Install dependencies
WORKDIR /app
COPY package.json postinstall.sh /app/
RUN apt-get -q update \
&& apt-get install -qqy g++ libsqlite3-dev make --no-install-recommends \
&& JOBS=MAX npm install --unsafe-perm --production --no-optional \
&& npm dedupe \
&& npm cache clean \
&& rm -rf /tmp/* \
&& apt-get purge -qqy g++ libsqlite3-dev make binutils \
&& apt-get clean \
&& apt-get autoremove -qqy \
&& rm -rf /var/lib/apt/lists/
# Copy source
COPY . /app/
RUN /app/node_modules/.bin/coffee -c /app/src \
&& ln -sf /app/entry.sh /start # Needed for legacy
RUN chmod +x /app/bin/gosuper
ENV SUPERVISOR_IMAGE resin/i386-supervisor
ENV CONFIG_MOUNT_POINT /boot/config.json
ENV LED_FILE /dev/null
ENTRYPOINT ["/app/entry.sh"]

View File

@ -1,53 +0,0 @@
FROM resin/rpi-node:0.10.40-slim
COPY 01_nodoc /etc/dpkg/dpkg.cfg.d/
ENV DOCKER_COMPOSE_VERSION 1.7.1
ENV DOCKER_COMPOSE_SHA256 3f0b8c69c66a2daa5fbb0c127cb76ca95d7125827a9c43dd3c36f9bc2ed6e0e5
# Supervisor apt dependencies
RUN apt-get -q update \
&& apt-get install -qqy \
btrfs-tools \
ca-certificates \
curl \
iptables \
rsync \
supervisor \
--no-install-recommends \
&& curl -sLO http://resin-packages.s3.amazonaws.com/docker-compose/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& echo $DOCKER_COMPOSE_SHA256 docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz > docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& sha256sum -c docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz.sha256 \
&& tar xzf docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}.tar.gz \
&& mv docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}/docker-compose-linux-armhf /usr/bin/docker-compose \
&& rm -rf docker-compose-linux-armhf-${DOCKER_COMPOSE_VERSION}* \
&& apt-get purge -qqy curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/
# Copy supervisord configuration files
COPY config/supervisor/ /etc/supervisor/
# Install dependencies
WORKDIR /app
COPY package.json postinstall.sh /app/
RUN apt-get -q update \
&& apt-get install -qqy g++ libsqlite3-dev make --no-install-recommends \
&& JOBS=MAX npm install --unsafe-perm --production --no-optional \
&& npm dedupe \
&& npm cache clean \
&& rm -rf /tmp/* \
&& apt-get purge -qqy g++ libsqlite3-dev make binutils \
&& apt-get clean \
&& apt-get autoremove -qqy \
&& rm -rf /var/lib/apt/lists/
# Copy source
COPY . /app/
RUN /app/node_modules/.bin/coffee -c /app/src \
&& ln -sf /app/entry.sh /start # Needed for legacy
RUN chmod +x /app/bin/gosuper
ENTRYPOINT ["/app/entry.sh"]

View File

@ -0,0 +1,20 @@
# Minimal runtime image
FROM resin/%%ARCH%%-supervisor-base:20160913
WORKDIR /usr/src/app
COPY ./build/%%ARCH%%/src ./src
COPY ./build/%%ARCH%%/node_modules ./node_modules
COPY ./build/%%ARCH%%/gosuper ./gosuper
COPY ./build/%%ARCH%%/rootfs-overlay/ /
VOLUME /data
ENV CONFIG_MOUNT_POINT /boot/config.json \
LED_FILE /dev/null \
SUPERVISOR_IMAGE resin/%%ARCH%%-supervisor
CMD [ "/sbin/init" ]
# -*- mode: dockerfile -*-
# vi: set ft=dockerfile :

125
Makefile
View File

@ -21,12 +21,10 @@ endif
DISABLE_CACHE = 'false'
ARCH = rpi# rpi/amd64/i386/armv7hf/armel
BASE_DISTRO =
DEPLOY_REGISTRY =
SUPERVISOR_VERSION = master
JOB_NAME = 1
all: supervisor
@ -36,15 +34,8 @@ MIXPANEL_TOKEN = bananasbananas
PASSWORDLESS_DROPBEAR = false
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
IMAGE = "resin/$(ARCH)-supervisor:$(SUPERVISOR_VERSION)"
DOCKERFILE = $(ARCH)
SUPERVISOR_IMAGE=$(DEPLOY_REGISTRY)$(IMAGE)
@ -78,9 +69,6 @@ endif
SUPERVISOR_EXTRA_MOUNTS =
clean:
-rm Dockerfile
DOCKERD_PROXY=tools/dind/config/services/docker.service.d/proxy.conf
${DOCKERD_PROXY}:
rm -f ${DOCKERD_PROXY}
@ -103,7 +91,14 @@ ${DOCKERD_PROXY}:
fi
supervisor-dind: ${DOCKERD_PROXY}
cd tools/dind && docker build $(DOCKER_HTTP_PROXY) $(DOCKER_HTTPS_PROXY) $(DOCKER_NO_PROXY) --no-cache=$(DISABLE_CACHE) --build-arg PASSWORDLESS_DROPBEAR=$(PASSWORDLESS_DROPBEAR) -t resin/resin-supervisor-dind:$(SUPERVISOR_VERSION) .
cd tools/dind \
&& docker build \
$(DOCKER_HTTP_PROXY) \
$(DOCKER_HTTPS_PROXY) \
$(DOCKER_NO_PROXY) \
--no-cache=$(DISABLE_CACHE) \
--build-arg PASSWORDLESS_DROPBEAR=$(PASSWORDLESS_DROPBEAR) \
-t resin/resin-supervisor-dind:$(SUPERVISOR_VERSION) .
run-supervisor: stop-supervisor supervisor-dind
cd tools/dind \
@ -136,54 +131,86 @@ refresh-supervisor-src:
&& echo " * Restarting supervisor container.." \
&& docker exec -ti resin_supervisor_1 docker restart resin_supervisor
supervisor: gosuper
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
echo "ENV DEFAULT_MIXPANEL_TOKEN $(MIXPANEL_TOKEN)" >> Dockerfile
supervisor: nodesuper gosuper
sed 's/%%ARCH%%/$(ARCH)/g' Dockerfile.runtime.template > Dockerfile.runtime.$(ARCH)
echo "ENV VERSION $(shell jq -r .version package.json) \\" >> Dockerfile.runtime.$(ARCH)
echo " DEFAULT_PUBNUB_PUBLISH_KEY $(PUBNUB_PUBLISH_KEY) \\" >> Dockerfile.runtime.$(ARCH)
echo " DEFAULT_PUBNUB_SUBSCRIBE_KEY $(PUBNUB_SUBSCRIBE_KEY) \\" >> Dockerfile.runtime.$(ARCH)
echo " DEFAULT_MIXPANEL_TOKEN $(MIXPANEL_TOKEN)" >> Dockerfile.runtime.$(ARCH)
ifdef rt_https_proxy
echo "ENV HTTPS_PROXY $(rt_https_proxy)" >> Dockerfile
echo "ENV https_proxy $(rt_https_proxy)" >> Dockerfile
echo "ENV HTTPS_PROXY $(rt_https_proxy) \\" >> Dockerfile.runtime.$(ARCH)
echo " https_proxy $(rt_https_proxy)" >> Dockerfile.runtime.$(ARCH)
endif
ifdef rt_http_proxy
echo "ENV HTTP_PROXY $(rt_http_proxy)" >> Dockerfile
echo "ENV http_proxy $(rt_http_proxy)" >> Dockerfile
echo "ENV HTTP_PROXY $(rt_http_proxy) \\" >> Dockerfile.runtime.$(ARCH)
echo " http_proxy $(rt_http_proxy)" >> Dockerfile.runtime.$(ARCH)
endif
ifdef rt_no_proxy
echo "ENV no_proxy $(rt_no_proxy)" >> Dockerfile
echo "ENV no_proxy $(rt_no_proxy)" >> Dockerfile.runtime.$(ARCH)
endif
docker build $(DOCKER_HTTP_PROXY) $(DOCKER_HTTPS_PROXY) $(DOCKER_NO_PROXY) --no-cache=$(DISABLE_CACHE) -t $(IMAGE) .
-rm Dockerfile
docker build \
$(DOCKER_HTTP_PROXY) \
$(DOCKER_HTTPS_PROXY) \
$(DOCKER_NO_PROXY) \
-f Dockerfile.runtime.$(ARCH) \
--pull \
-t $(IMAGE) .
lint: supervisor
docker run --rm --entrypoint='sh' $(IMAGE) -c 'npm install && npm run lint'
lint:
docker run --rm resin/node-supervisor-$(ARCH):$(SUPERVISOR_VERSION) bash -c 'npm install resin-lint && npm run lint'
deploy: supervisor
docker tag -f $(IMAGE) $(SUPERVISOR_IMAGE)
bash retry_docker_push.sh $(SUPERVISOR_IMAGE)
go-builder:
-cp tools/dind/config.json ./gosuper/
cd gosuper && docker build $(DOCKER_HTTP_PROXY) $(DOCKER_HTTPS_PROXY) $(DOCKER_NO_PROXY) -t resin/go-supervisor-builder:$(SUPERVISOR_VERSION) .
-rm ./gosuper/config.json
nodesuper:
sed 's/%%ARCH%%/$(ARCH)/g' Dockerfile.build.template > Dockerfile.build.$(ARCH)
docker build \
$(DOCKER_HTTP_PROXY) \
$(DOCKER_HTTPS_PROXY) \
$(DOCKER_NO_PROXY) \
-f Dockerfile.build.$(ARCH) \
-t resin/node-supervisor-$(ARCH):$(SUPERVISOR_VERSION) .
docker run --rm \
-v `pwd`/build/$(ARCH):/build \
resin/node-supervisor-$(ARCH):$(SUPERVISOR_VERSION)
gosuper: go-builder
-mkdir -p bin
-docker rm --volumes -f resin_build_gosuper_$(JOB_NAME) || true
docker run --rm --name resin_build_gosuper_$(JOB_NAME) -v $(shell pwd)/gosuper/bin:/usr/src/app/bin -e USER_ID=$(shell id -u) -e GROUP_ID=$(shell id -g) -e GOARCH=$(GOARCH) -e GOARM=$(GOARM) resin/go-supervisor-builder:$(SUPERVISOR_VERSION)
mv gosuper/bin/linux_$(GOARCH)/gosuper bin/gosuper
gosuper:
cd gosuper && docker build \
$(DOCKER_HTTP_PROXY) \
$(DOCKER_HTTPS_PROXY) \
$(DOCKER_NO_PROXY) \
--build-arg GOARCH=$(GOARCH) \
--build-arg GOARM=$(GOARM) \
-t resin/go-supervisor-$(ARCH):$(SUPERVISOR_VERSION) .
docker run --rm \
-v `pwd`/build/$(ARCH):/build \
resin/go-supervisor-$(ARCH):$(SUPERVISOR_VERSION)
test-gosuper: go-builder
-docker rm --volumes -f resin_test_gosuper_$(JOB_NAME) || true
docker run --rm --name resin_test_gosuper_$(JOB_NAME) -v /var/run/dbus:/mnt/root/run/dbus -e DBUS_SYSTEM_BUS_ADDRESS="unix:path=/mnt/root/run/dbus/system_bus_socket" resin/go-supervisor-builder:$(SUPERVISOR_VERSION) bash -c "cd src/resin-supervisor/gosuper && ./test_formatting.sh && go test -v ./gosuper"
test-gosuper: gosuper
docker run \
--rm \
-v /var/run/dbus:/mnt/root/run/dbus \
-e DBUS_SYSTEM_BUS_ADDRESS="unix:path=/mnt/root/run/dbus/system_bus_socket" \
resin/go-supervisor-$(ARCH):$(SUPERVISOR_VERSION) bash -c \
'./test_formatting.sh && go test -v ./gosuper'
format-gosuper: go-builder
-docker rm --volumes -f resin_test_gosuper_$(JOB_NAME) || true
docker run --rm --name resin_test_gosuper_$(JOB_NAME) -v $(shell pwd)/gosuper:/usr/src/app/src/resin-supervisor/gosuper resin/go-supervisor-builder:$(SUPERVISOR_VERSION) bash -c "cd src/resin-supervisor/gosuper && go fmt ./..."
format-gosuper: gosuper
docker run \
--rm \
-v $(shell pwd)/gosuper:/go/src/resin-supervisor/gosuper \
resin/go-supervisor-$(ARCH):$(SUPERVISOR_VERSION) \
go fmt ./...
test-integration: go-builder
-docker rm --volumes -f resin_test_integration_$(JOB_NAME) || true
docker run --rm --name resin_test_integration_$(JOB_NAME) --net=host -e SUPERVISOR_IP="$(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' resin_supervisor_1)" --volumes-from resin_supervisor_1 -v /var/run/dbus:/mnt/root/run/dbus -e DBUS_SYSTEM_BUS_ADDRESS="unix:path=/mnt/root/run/dbus/system_bus_socket" resin/go-supervisor-builder:$(SUPERVISOR_VERSION) bash -c "cd src/resin-supervisor/gosuper && go test -v ./supertest"
test-integration: gosuper
docker run \
--rm \
--net=host \
-e SUPERVISOR_IP="$(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' resin_supervisor_1)" \
--volumes-from resin_supervisor_1 \
-v /var/run/dbus:/mnt/root/run/dbus \
-e DBUS_SYSTEM_BUS_ADDRESS="unix:path=/mnt/root/run/dbus/system_bus_socket" \
resin/go-supervisor-$(ARCH):$(SUPERVISOR_VERSION) \
go test -v ./supertest
.PHONY: supervisor deploy supervisor-dind run-supervisor
.PHONY: supervisor deploy supervisor-dind run-supervisor gosuper nodesuper

View File

@ -12,15 +12,10 @@ docker pull resin/${ARCH}-supervisor:${ESCAPED_BRANCH_NAME} || docker pull resin
make SUPERVISOR_VERSION=${VERSION} JOB_NAME=${JOB_NAME} test-gosuper
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} \
lint
make ${MAKE_ARGS} \
SUPERVISOR_VERSION=${ESCAPED_BRANCH_NAME} \
DEPLOY_REGISTRY= \

View File

@ -1,10 +0,0 @@
[program:go-supervisor]
directory=/app
command=/app/bin/gosuper
redirect_stderr=true
autorestart=true
autostart=false
stdout_logfile=/var/log/go_supervisor_stdout.log
stderr_logfile=/var/log/go_supervisor_error.log
stdout_logfile_maxbytes=2MB
stdout_logfile_backups=5

View File

@ -1,10 +0,0 @@
[program:resin-supervisor]
directory=/app
command=node src/app.js
redirect_stderr=true
autorestart=true
autostart=false
stdout_logfile=/var/log/resin_supervisor_stdout.log
stderr_logfile=/var/log/resin_supervisor_error.log
stdout_logfile_maxbytes=2MB
stdout_logfile_backups=5

View File

@ -1,28 +0,0 @@
; supervisor config file
[unix_http_server]
file=/var/run/resin/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/resin/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/resin/supervisor.sock ; use a unix:// URL for a unix socket
; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.
[include]
files = /etc/supervisor/conf.d/*.conf

BIN
empty.tar

Binary file not shown.

View File

@ -1,43 +0,0 @@
#!/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"
# If DOCKER_ROOT isn't set then default it
if [ -z "${DOCKER_ROOT}" ]; then
DOCKER_ROOT=/mnt/root/var/lib/rce
fi
# Mount the DOCKER_ROOT path equivalent in the container fs
DOCKER_LIB_PATH=${DOCKER_ROOT#/mnt/root}
if [ ! -d "${DOCKER_LIB_PATH}" ]; then
ln -s "${DOCKER_ROOT}" "${DOCKER_LIB_PATH}"
fi
/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 \
/var/log/resin_supervisor_stdout.log

View File

@ -1,45 +1,22 @@
#!/bin/sh
set -e
set -o errexit
[ -d /dev/net ] ||
mkdir -p /dev/net
[ -c /dev/net/tun ] ||
mknod /dev/net/tun c 10 200
cd /app
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"
# If DOCKER_ROOT isn't set then default it
if [ -z "${DOCKER_ROOT}" ]; then
DOCKER_ROOT=/mnt/root/var/lib/rce
fi
# Mount the DOCKER_ROOT path equivalent in the container fs
DOCKER_LIB_PATH=${DOCKER_ROOT#/mnt/root}
if [ ! -d "${DOCKER_LIB_PATH}" ]; then
ln -s "${DOCKER_ROOT}" "${DOCKER_LIB_PATH}"
fi
/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
supervisorctl start resin-supervisor
supervisorctl start go-supervisor
tail -F \
/var/log/supervisor/supervisord.log \
/var/log/resin_supervisor_stdout.log

View File

@ -1,15 +1,24 @@
FROM golang:1.5.1
# Build golang supervisor
FROM golang:1.6
RUN apt-get update \
&& apt-get install -y \
rsync \
upx-ucl \
&& rm -rf /var/lib/apt/lists/
COPY . /go/src/resin-supervisor/gosuper
WORKDIR /go/src/resin-supervisor/gosuper
ENV GOOS linux
ENV GOPATH /usr/src/app
WORKDIR /usr/src/app
ARG GOARCH=amd64
ARG GOARM=''
COPY . src/resin-supervisor/gosuper
RUN go install -a -v ./gosuper \
&& cd /go/bin \
&& find -type f -name gosuper -exec mv {} /go/bin/gosuper \; \
&& upx --best /go/bin/gosuper
RUN chmod +x src/resin-supervisor/gosuper/build_gosuper.sh
RUN chmod +x src/resin-supervisor/gosuper/test_formatting.sh
# Run go install with -a (force rebuilding of all packages)
# and -v (print package names as they are built)
CMD cd ./src/resin-supervisor/gosuper && ./build_gosuper.sh
CMD rsync -a --delete /go/bin/gosuper /build

View File

@ -1,14 +0,0 @@
#!/bin/bash
go install -a -v ./gosuper
RETURN_VALUE=$?
HOSTARCH=$(uname -m)
# For consistency, always keep the binary within a linux_$GOARCH folder
if [[ ( $GOARCH == "amd64" && $HOSTARCH == "x86_64" ) || ( $GOARCH == "arm" && $HOSTARCH == "armv7l" ) ]]; then
mkdir -p $GOPATH/bin/linux_$GOARCH
cp $GOPATH/bin/gosuper $GOPATH/bin/linux_$GOARCH/
fi
chown -R $USER_ID:$GROUP_ID $GOPATH/bin
exit $RETURN_VALUE

7
inittab Normal file
View File

@ -0,0 +1,7 @@
# busybox inittab
# format: tty:ignored:action:command
stdout::sysinit:/usr/src/app/entry.sh
stdout::respawn:/usr/src/app/run.sh node /usr/src/app/src/app.js
stdout::respawn:/usr/src/app/run.sh /usr/src/app/gosuper

View File

@ -2,8 +2,8 @@
"name": "resin-supervisor",
"version": "2.1.1",
"scripts": {
"postinstall": "sh postinstall.sh",
"start": "./entry.sh",
"build": "coffee -c src",
"lint": "resin-lint src/"
},
"dependencies": {
@ -12,7 +12,6 @@
"bluebird": "^2.9.24",
"body-parser": "^1.12.0",
"buffer-equal-constant-time": "^1.0.1",
"coffee-script": "~1.10.0",
"docker-delta": "0.0.11",
"docker-progress": "^2.1.0",
"docker-toolbelt": "^1.0.0",
@ -33,7 +32,7 @@
"resin-register-device": "^2.0.0",
"rimraf": "^2.5.4",
"rwlock": "^5.0.0",
"sqlite3": "3.0.9",
"sqlite3": "^3.1.0",
"typed-error": "~0.1.0",
"yamljs": "^0.2.7"
},
@ -41,6 +40,7 @@
"node": "0.10.22"
},
"devDependencies": {
"coffee-script": "~1.10.0",
"resin-lint": "^1.3.1"
}
}

View File

@ -1,19 +0,0 @@
set -o errexit
if [ "$NODE_ENV" = "production" ]; then
# Remove node-gyp cache
rm -rf ~/.node-gyp/
# Remove cached git deps
rm -rf /tmp/*
# Remove the c files we no longer need (the sqlite3 node module has a massive ~5M c file)
find . -name '*.c' -delete
# And the tar files (sqlite3 module again)
find . -name '*.tar.*' -delete
# Who needs tests and docs? Pffft! - Ignoring errors because find isn't a fan of us deleting directories whilst it's trying to search within them.
find . -type d -name 'test' -exec rm -rf '{}' \; 2> /dev/null || true
find . -type d -name 'doc' -exec rm -rf '{}' \; 2> /dev/null || true
find . -type d -name 'man' -exec rm -rf '{}' \; 2> /dev/null || true
# And any benchmark results (ttyjs->socket.io->socket.io-client->active-x-obfuscator->zeparser has an 8MB benchmark.html)
find . -type d -name 'benchmark*' -exec rm -rf '{}' \; 2> /dev/null || true
find . -name 'benchmark*' -delete
fi

22
run.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
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"
# If DOCKER_ROOT isn't set then default it
if [ -z "${DOCKER_ROOT}" ]; then
DOCKER_ROOT=/mnt/root/var/lib/rce
fi
exec $@