2017-07-07 21:47:28 +00:00
|
|
|
ARG ARCH=amd64
|
2020-03-31 17:09:21 +00:00
|
|
|
ARG NODE_VERSION=10.19.0
|
2017-12-14 03:55:26 +00:00
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
FROM balenalib/$ARCH-alpine-supervisor-base:3.11 as BUILD
|
2019-06-24 13:19:00 +00:00
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
ARG ARCH
|
|
|
|
ARG NODE_VERSION
|
|
|
|
ARG NODE_ARCHIVE="node-no-intl-v${NODE_VERSION}-linux-alpine-${ARCH}.tar.gz"
|
|
|
|
ARG S3_BASE="https://resin-packages.s3.amazonaws.com"
|
|
|
|
ARG NODE_LOCATION="${S3_BASE}/node/v${NODE_VERSION}/${NODE_ARCHIVE}"
|
|
|
|
|
|
|
|
# DO NOT REMOVE THE cross-build-* COMMANDS
|
|
|
|
# The following commands are absolutely needed. When we
|
|
|
|
# build for ARM architectures, we run this Dockerfile
|
|
|
|
# through sed, which uncomments these lines. There were
|
|
|
|
# other options for achieving the same setup, but this seems
|
|
|
|
# to be the least intrusive. The commands start commented
|
|
|
|
# out because the default build for balenaCI is amd64 (and
|
|
|
|
# we can't run any sed preprocessing on it there)
|
|
|
|
# RUN ["cross-build-start"]
|
2017-07-07 21:47:28 +00:00
|
|
|
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
RUN apk add --no-cache \
|
2019-05-09 11:15:47 +00:00
|
|
|
g++ \
|
|
|
|
git \
|
|
|
|
make \
|
|
|
|
python \
|
2019-06-24 13:19:00 +00:00
|
|
|
curl \
|
2020-03-31 17:09:21 +00:00
|
|
|
binutils \
|
|
|
|
libgcc \
|
|
|
|
libstdc++ \
|
|
|
|
libuv
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
COPY build-conf/node-sums.txt .
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
# Install node from balena's prebuilt cache
|
|
|
|
RUN curl -SLO "${NODE_LOCATION}" \
|
|
|
|
&& grep "${NODE_ARCHIVE}" node-sums.txt | sha256sum -c - \
|
|
|
|
&& tar -xzf "${NODE_ARCHIVE}" -C /usr/local --strip-components=1 \
|
|
|
|
&& rm -f "${NODE_ARCHIVE}" \
|
|
|
|
&& strip /usr/local/bin/node
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
COPY package*.json ./
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
RUN npm ci
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
COPY webpack.config.js fix-jsonstream.js hardcode-migrations.js tsconfig.json tsconfig.release.json ./
|
|
|
|
COPY src ./src
|
|
|
|
COPY test ./test
|
|
|
|
COPY typings ./typings
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
RUN npm run test-nolint \
|
|
|
|
&& npm run build
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
# Run the production install here, to avoid the npm dependency on
|
|
|
|
# the later stage
|
|
|
|
RUN npm ci --production --no-optional --unsafe-perm \
|
|
|
|
&& npm cache clean --force \
|
|
|
|
# For some reason this doesn't get cleared with the other
|
|
|
|
# cache
|
|
|
|
&& rm -rf node_modules/.cache \
|
|
|
|
# Remove various uneeded filetypes in order to reduce space
|
|
|
|
# We also remove the spurious node.dtps, see https://github.com/mapbox/node-sqlite3/issues/861
|
|
|
|
&& 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' -o -name "*.ts" \
|
|
|
|
-delete \
|
|
|
|
&& find . -type f -path '*/node_modules/sqlite3/deps*' -delete \
|
|
|
|
&& find . -type f -path '*/node_modules/knex/build*' -delete \
|
|
|
|
&& rm -rf node_modules/sqlite3/node.dtps
|
|
|
|
|
|
|
|
|
|
|
|
# RUN ["cross-build-end"]
|
|
|
|
|
|
|
|
FROM balenalib/$ARCH-alpine-supervisor-base:3.11
|
|
|
|
|
|
|
|
# RUN ["cross-build-start"]
|
|
|
|
|
|
|
|
RUN apk add --no-cache \
|
|
|
|
ca-certificates \
|
|
|
|
kmod \
|
|
|
|
iptables \
|
|
|
|
ip6tables \
|
|
|
|
rsync \
|
|
|
|
avahi \
|
|
|
|
dbus \
|
|
|
|
libstdc++
|
2017-07-07 21:47:28 +00:00
|
|
|
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
COPY --from=BUILD /usr/local/bin/node /usr/local/bin/node
|
|
|
|
COPY --from=BUILD /usr/src/app/dist ./dist
|
|
|
|
COPY --from=BUILD /usr/src/app/package.json ./
|
|
|
|
COPY --from=BUILD /usr/src/app/node_modules ./node_modules
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
COPY entry.sh .
|
2018-07-27 13:18:13 +00:00
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
RUN mkdir -p rootfs-overlay && \
|
|
|
|
(([ ! -d rootfs-overlay/lib64 ] && ln -s /lib rootfs-overlay/lib64) || true)
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2019-07-19 15:54:06 +00:00
|
|
|
ARG ARCH
|
|
|
|
ARG VERSION=master
|
|
|
|
ARG DEFAULT_MIXPANEL_TOKEN=bananasbananas
|
2017-07-07 21:47:28 +00:00
|
|
|
ENV CONFIG_MOUNT_POINT=/boot/config.json \
|
|
|
|
LED_FILE=/dev/null \
|
2020-03-31 17:09:21 +00:00
|
|
|
SUPERVISOR_IMAGE=balena/$ARCH-supervisor \
|
2017-07-07 21:47:28 +00:00
|
|
|
VERSION=$VERSION \
|
|
|
|
DEFAULT_MIXPANEL_TOKEN=$DEFAULT_MIXPANEL_TOKEN
|
2020-03-31 17:09:21 +00:00
|
|
|
COPY avahi-daemon.conf /etc/avahi/avahi-daemon.conf
|
2017-07-07 21:47:28 +00:00
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
VOLUME /data
|
2017-12-08 08:26:32 +00:00
|
|
|
HEALTHCHECK --interval=5m --start-period=1m --timeout=30s --retries=3 \
|
2020-03-31 17:09:21 +00:00
|
|
|
CMD wget http://127.0.0.1:${LISTEN_PORT:-48484}/v1/healthy -O - -q
|
|
|
|
|
|
|
|
# RUN ["cross-build-end"]
|
2018-03-16 14:01:50 +00:00
|
|
|
|
2020-03-31 17:09:21 +00:00
|
|
|
CMD ["/usr/src/app/entry.sh"]
|