File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed
Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change 11ARG BUILD_FROM
2- FROM $BUILD_FROM
2+ FROM $BUILD_FROM as base
33
44ENV LANG C.UTF-8
55ARG BUILD_VERSION
66
7- RUN apk add --no-cache --virtual .build-dependencies make gcc g++ linux-headers udev git python3 && \
8- apk add --no-cache nodejs npm socat tini && \
7+ RUN apk add --no-cache socat tini nodejs
8+
9+ # Dependencies and build
10+ FROM base as dependencies_and_build
11+
12+ RUN apk add --no-cache --virtual .buildtools npm make gcc g++ linux-headers udev git python3 && \
913 if [ "${BUILD_VERSION}" = "edge" ]; \
1014 then \
1115 echo "Installing Edge version" && \
@@ -27,12 +31,20 @@ RUN apk add --no-cache --virtual .build-dependencies make gcc g++ linux-headers
2731 npm ci --no-audit --no-optional --no-update-notifier --unsafe-perm && \
2832 npm run build && \
2933 rm -rf node_modules && \
30- npm ci --no-audit --no-optional --no-update-notifier --only=production --unsafe-perm && \
31- apk del --no-cache --purge .build-dependencies && \
32- rm -rf docs test images data docker LICENSE README.md update.sh lib && \
33- rm -rf /root/.cache /root/.npm
34+ npm ci --no-audit --no-optional --no-update-notifier --production --unsafe-perm && \
35+ # Serialport needs to be rebuild for Alpine https://serialport.io/docs/9.x.x/guide-installation#alpine-linux
36+ npm rebuild --build-from-source && \
37+ apk del .buildtools
38+
39+ # Release
40+ FROM base as release
41+
42+ WORKDIR /app
3443
3544COPY rootfs /
45+ COPY --from=dependencies_and_build /app/node_modules ./node_modules
46+ COPY --from=dependencies_and_build /app/dist ./dist
47+ COPY --from=dependencies_and_build /app/package.json /app/LICENSE /app/index.js ./
3648
3749ENV NODE_ENV production
3850
You can’t perform that action at this time.
0 commit comments