File tree Expand file tree Collapse file tree 2 files changed +20
-7
lines changed Expand file tree Collapse file tree 2 files changed +20
-7
lines changed Original file line number Diff line number Diff line change 11# Don't send node_modules the daemon - we want the build server to install these.
2- node_modules /
2+ node_modules
3+ npm-debug.log
34.git
4- repo.yml
5+ .gitignore
Original file line number Diff line number Diff line change 11# base-image for node on any machine using a template variable,
22# see more about dockerfile templates here: https://www.balena.io/docs/learn/develop/dockerfile/#dockerfile-templates
33# and about balena base images here: https://www.balena.io/docs/reference/base-images/base-images/
4- FROM node:22-bookworm-slim
4+ # The image being used to build the application in multi-stage build
5+ FROM node:22-bookworm-slim AS build
56
67# Defines our working directory in container
7- WORKDIR /usr/src/app
8+ WORKDIR /build
89
910# Copies the package.json first for better cache on later pushes
1011COPY package*.json ./
1112
1213# This install npm dependencies on the balena build server,
1314# making sure to clean up the artifacts it creates in order to reduce the image size.
14- RUN JOBS=MAX npm install --production --unsafe-perm && npm cache verify && rm -rf /tmp/*
15+ RUN JOBS=MAX npm ci --omit=dev
1516
1617# This will copy all files in our root to the working directory in the container
1718COPY . ./
1819
19- # server.js will run when container starts up on the device
20- CMD ["npm", "start"]
20+ # Image that will be used to run the application
21+ FROM node:22-bookworm-slim
22+
23+ ENV NODE_ENV production
24+ WORKDIR /usr/src/app
25+
26+ COPY --from=build /build .
27+
28+ # Use node user instead of root for security
29+ USER node
30+
31+ # Use exec form for better signal handling
32+ CMD ["node", "server.js"]
You can’t perform that action at this time.
0 commit comments