We have this multi-container build that has been working for years we are experiencing a strange builder problem. Two days ago the build succeeded, yesterday there were missing images while building resulting in failed builds, and today the images are not missing but the typescript compilation is failing.
The containers all build locally, also the containers will build successfully each on their own when pushed to a test project.
** but when we push the composed project we get strange errors when trying to compile the typescript in two of the three containers. See Below
Any help on the topic is appreciated as we have run out of ideas.
Builder Error
[base] Step 13/30 : RUN npm run build
[base] ---> Running in 1692b70a8832
[base] > cloudcue-base@1.0.0 build /usr/src/app
[base] > rm -rf dist && tsc
[base] internal/modules/cjs/loader.js:969
[base] throw err;
[base] ^
[base] Error: Cannot find module '../lib/tsc.js'
[base] Require stack:
[base] - /usr/src/app/node_modules/.bin/tsc
[base] at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
[base] at Function.Module._load (internal/modules/cjs/loader.js:842:27)
[base] at Module.require (internal/modules/cjs/loader.js:1026:19)
[base] at require (internal/modules/cjs/helpers.js:72:18)
[base] at Object. (/usr/src/app/node_modules/.bin/tsc:2:1)
[base] at Module._compile (internal/modules/cjs/loader.js:1138:30)
[base] at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
[base] at Module.load (internal/modules/cjs/loader.js:986:32)
[base] at Function.Module._load (internal/modules/cjs/loader.js:879:14)
[base] at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
[base] code: 'MODULE_NOT_FOUND',
[base] requireStack: [ '/usr/src/app/node_modules/.bin/tsc' ]
[base] }
Compose.yaml
version: '2.1'
volumes:
client-data:
# external: true
services:
base:
build: ./base
image: cloudcue-client-base
container_name: cloudcue-base
restart: always
privileged: true
volumes:
- 'client-data:/var/lib/cloudcue'
expose:
- '80'
ports:
- '8088:80'
labels:
io.balena.features.supervisor-api: '1'
ui:
build: ./base-ui
image: cloudcue-client-base-ui
container_name: cloudcue-ui
restart: always
environment:
- API_HOST=base
- API_PORT=80
depends_on:
- base
expose:
- '80'
ports:
- '8080:80'
wpe:
build: ./tools/wpe
image: cloudcue-client-wpe
container_name: cloudcue-wpe
restart: always
privileged: true
environment:
- WPE_URL=http://ui:80
depends_on:
- ui
First Container [base]
# # *** Builder Container *** ---------------------------------------------------
FROM balenalib/raspberrypi3-alpine-node:12-build as build
# FROM node:10.15-alpine as build
# RUN apk --no-cache add --virtual native-deps \
# make g++ gcc python linux-headers udev libgcc libstdc++ wxgtk wxgtk-dev
WORKDIR /usr/src/
ADD ./BOSSA-1.7.0.tar.gz .
RUN make -C BOSSA-1.7.0 bin/bossac && cp BOSSA-1.7.0/bin/* /usr/local/bin/
WORKDIR /usr/src/app
COPY package.json ./
RUN npm set progress=false && npm config set depth 0
# install npm production dependencies
RUN npm install --only=production && npm cache verify
# copy production node_modules aside
RUN cp -R node_modules prod_node_modules
# install npm development dependencies
# making sure to clean up the artifacts it creates in order to reduce the image size.
RUN npm install --development && npm cache verify && rm -rf /tmp/*
# build app for production
COPY . ./
ENV NODE_ENV=production
RUN npm run build
# *** Production Container *** ------------------------------------------------
# FROM node:10.15-alpine
# FROM balenalib/%%BALENA_MACHINE_NAME%%-alpine
FROM balenalib/raspberrypi3-alpine-node:12-run as release
RUN apk --no-cache add alsa-lib
WORKDIR /usr/app
COPY package.json ./
# copy pre-compiled production node_modules
COPY --from=build /usr/src/app/prod_node_modules ./node_modules
# COPY --from=build /usr/src/app/node_modules/epoll node_modules/epoll
# COPY --from=build /usr/src/app/node_modules/@serialport node_modules/@serialport
COPY --from=build /usr/src/app/config config
COPY --from=build /usr/src/app/dist/src dist/src
COPY --from=build /usr/src/app/firmware firmware
COPY --from=build /usr/local/bin/bossac firmware/_arm/bossac
RUN chmod -R 755 /usr/app/firmware/_arm
COPY udev_pause.sh .
RUN chmod 755 udev_pause.sh
COPY udev.rules /etc/udev/rules.d/udev.rules
# setup environment
ENV UDEV=1
ENV NODE_ENV=production
EXPOSE 80
CMD npm start
