I’m trying to build our Node server which will use CAN on a RPi 4 via MCP2515 on SPI0 along with a MCP3008 ADC via SPI1.
My server is built using Typescript and I am trying to do a multi-stage build of the server build but I’m having a lot of trouble with missing dependancies when the
RUN npm install --production command is executed. It keeps getting build errors when trying to build the SPI, first is was missing python, then make and now it’s missing g++. I have the feeling I’m going about this the wrong way.
My docker-compose.yml is below, the
can-init service just brings up the CAN interface.
version: "2.0" services: can-init: build: "./can-init" # use this directory as the build context for the service network_mode: host # expose host network adaptors to the container directly cap_add: - NET_ADMIN # allow container to change network settings restart: no environment: CAN0_BITRATE: 250000 server: build: "./server" # use this directory as the build context for the service network_mode: host # expose host network adaptors to the container directly
My Dockerfile for the server is below:
# Build stage FROM balenalib/raspberrypi4-64-node:12-build as builder WORKDIR /app RUN install_packages iproute2 can-utils COPY . . RUN npm install RUN npm run clean RUN npm run build-server # Run stage FROM balenalib/raspberrypi4-64-node:12-run RUN install_packages iproute2 can-utils python make WORKDIR /app COPY --from=builder /app/lib ./lib COPY package*.json ./ RUN npm install --production CMD ["node", "-r", "dotenv/config", "./lib/index.js"]