2017-07-07 21:47:28 +00:00
|
|
|
ARG ARCH=amd64
|
|
|
|
|
|
|
|
# The node version here should match the version of the runtime image which is
|
|
|
|
# specified in the base-image subdirectory in the project
|
2018-04-09 10:54:55 +00:00
|
|
|
FROM resin/rpi-node:6.13.1-slim as rpi-node-base
|
|
|
|
FROM resin/armv7hf-node:6.13.1-slim as armv7hf-node-base
|
|
|
|
FROM resin/aarch64-node:6.13.1-slim as aarch64-node-base
|
2018-10-26 21:25:40 +00:00
|
|
|
RUN [ "cross-build-start" ]
|
|
|
|
RUN sed -i '/security.debian.org jessie/d' /etc/apt/sources.list
|
|
|
|
RUN [ "cross-build-end" ]
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2018-04-09 10:54:55 +00:00
|
|
|
FROM resin/amd64-node:6.13.1-slim as amd64-node-base
|
2017-07-07 21:47:28 +00:00
|
|
|
RUN echo '#!/bin/sh\nexit 0' > /usr/bin/cross-build-start && chmod +x /usr/bin/cross-build-start \
|
|
|
|
&& echo '#!/bin/sh\nexit 0' > /usr/bin/cross-build-end && chmod +x /usr/bin/cross-build-end
|
|
|
|
|
2018-04-09 10:54:55 +00:00
|
|
|
FROM resin/i386-node:6.13.1-slim as i386-node-base
|
2017-07-07 21:47:28 +00:00
|
|
|
RUN echo '#!/bin/sh\nexit 0' > /usr/bin/cross-build-start && chmod +x /usr/bin/cross-build-start \
|
|
|
|
&& echo '#!/bin/sh\nexit 0' > /usr/bin/cross-build-end && chmod +x /usr/bin/cross-build-end
|
|
|
|
|
2017-10-24 17:50:32 +00:00
|
|
|
FROM i386-node-base as i386-nlp-node-base
|
|
|
|
|
2017-12-14 03:55:26 +00:00
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
# We always do the webpack build on amd64, cause it's way faster
|
|
|
|
FROM amd64-node-base as node-build
|
|
|
|
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install -y \
|
|
|
|
g++ \
|
|
|
|
git \
|
|
|
|
libsqlite3-dev \
|
|
|
|
make \
|
|
|
|
python \
|
|
|
|
rsync \
|
|
|
|
wget \
|
|
|
|
&& rm -rf /var/lib/apt/lists/
|
|
|
|
|
|
|
|
COPY package.json /usr/src/app/
|
|
|
|
|
|
|
|
RUN JOBS=MAX npm install --no-optional --unsafe-perm
|
|
|
|
|
2018-04-27 13:27:42 +00:00
|
|
|
COPY webpack.config.js fix-jsonstream.js hardcode-migrations.js tsconfig.json /usr/src/app/
|
2017-12-14 03:55:26 +00:00
|
|
|
COPY src /usr/src/app/src
|
2018-04-04 13:04:55 +00:00
|
|
|
COPY test /usr/src/app/test
|
2018-05-01 11:05:53 +00:00
|
|
|
COPY typings /usr/src/app/typings
|
2017-12-14 03:55:26 +00:00
|
|
|
|
2018-04-04 13:04:55 +00:00
|
|
|
RUN npm test \
|
2017-12-14 03:55:26 +00:00
|
|
|
&& npm run build
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
|
2017-07-07 21:47:28 +00:00
|
|
|
# Build nodejs dependencies
|
2017-12-14 03:55:26 +00:00
|
|
|
FROM $ARCH-node-base as node-deps
|
2017-07-07 21:47:28 +00:00
|
|
|
ARG ARCH
|
|
|
|
|
|
|
|
RUN [ "cross-build-start" ]
|
|
|
|
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install -y \
|
|
|
|
g++ \
|
2017-08-29 07:23:51 +00:00
|
|
|
git \
|
2017-07-07 21:47:28 +00:00
|
|
|
libsqlite3-dev \
|
|
|
|
make \
|
|
|
|
python \
|
|
|
|
rsync \
|
|
|
|
wget \
|
|
|
|
&& rm -rf /var/lib/apt/lists/
|
|
|
|
|
|
|
|
RUN mkdir -p rootfs-overlay && \
|
|
|
|
ln -s /lib rootfs-overlay/lib64
|
|
|
|
|
|
|
|
COPY package.json /usr/src/app/
|
|
|
|
|
|
|
|
# Install only the production modules that have C extensions
|
|
|
|
RUN JOBS=MAX npm install --production --no-optional --unsafe-perm \
|
2017-12-14 03:55:26 +00:00
|
|
|
&& npm dedupe
|
2017-07-07 21:47:28 +00:00
|
|
|
|
|
|
|
# Remove various uneeded filetypes in order to reduce space
|
2017-08-25 18:02:07 +00:00
|
|
|
# We also remove the spurious node.dtps, see https://github.com/mapbox/node-sqlite3/issues/861
|
2017-07-07 21:47:28 +00:00
|
|
|
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/sqlite3/deps*' -delete \
|
2017-08-25 18:02:07 +00:00
|
|
|
&& find . -type f -path '*/node_modules/knex/build*' -delete \
|
|
|
|
&& rm -rf node_modules/sqlite3/node.dtps
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2018-03-16 14:01:50 +00:00
|
|
|
COPY entry.sh package.json rootfs-overlay/usr/src/app/
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2017-12-14 03:55:26 +00:00
|
|
|
RUN rsync -a --delete node_modules rootfs-overlay /build
|
2017-07-07 21:47:28 +00:00
|
|
|
|
|
|
|
RUN [ "cross-build-end" ]
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
# Minimal runtime image
|
2018-07-27 13:18:13 +00:00
|
|
|
FROM resin/$ARCH-supervisor-base:v1.3.0
|
2017-07-07 21:47:28 +00:00
|
|
|
ARG ARCH
|
|
|
|
ARG VERSION=master
|
|
|
|
ARG DEFAULT_MIXPANEL_TOKEN=bananasbananas
|
|
|
|
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
2017-12-14 03:55:26 +00:00
|
|
|
COPY --from=node-build /usr/src/app/dist ./dist
|
|
|
|
COPY --from=node-deps /build/node_modules ./node_modules
|
|
|
|
COPY --from=node-deps /build/rootfs-overlay/ /
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2018-07-27 13:18:13 +00:00
|
|
|
# Remove default nproc limit for Avahi for it to work in-container
|
|
|
|
COPY avahi-daemon.conf /etc/avahi/avahi-daemon.conf
|
|
|
|
|
2017-07-07 21:47:28 +00:00
|
|
|
VOLUME /data
|
|
|
|
|
|
|
|
ENV CONFIG_MOUNT_POINT=/boot/config.json \
|
|
|
|
LED_FILE=/dev/null \
|
|
|
|
SUPERVISOR_IMAGE=resin/$ARCH-supervisor \
|
|
|
|
VERSION=$VERSION \
|
|
|
|
DEFAULT_MIXPANEL_TOKEN=$DEFAULT_MIXPANEL_TOKEN
|
|
|
|
|
2017-12-08 08:26:32 +00:00
|
|
|
HEALTHCHECK --interval=5m --start-period=1m --timeout=30s --retries=3 \
|
|
|
|
CMD wget -qO- http://127.0.0.1:${LISTEN_PORT:-48484}/v1/healthy || exit 1
|
2018-03-16 14:01:50 +00:00
|
|
|
|
|
|
|
CMD [ "./entry.sh" ]
|