File tree Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Expand file tree Collapse file tree 2 files changed +21
-11
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 1- # base-image for node on any machine using a template variable,
21# see more about dockerfile templates here: https://www.balena.io/docs/learn/develop/dockerfile/#dockerfile-templates
3- # and about balena base images here: https://www.balena.io/docs/reference/base-images/base-images/
4- FROM node:22-bookworm-slim
2+ # The image being used to build the application in multi-stage build
3+ FROM node:22-bookworm-slim AS build
54
65# Defines our working directory in container
7- WORKDIR /usr/src/app
6+ WORKDIR /build
87
98# Copies the package.json first for better cache on later pushes
109COPY package*.json ./
1110
12- # This install npm dependencies on the balena build server,
13- # 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/*
11+ # Install npm dependencies
12+ RUN JOBS=MAX npm ci --omit=dev
1513
1614# This will copy all files in our root to the working directory in the container
1715COPY . ./
1816
19- # server.js will run when container starts up on the device
20- CMD ["npm", "start"]
17+ # Image that will be used to run the application
18+ FROM node:22-bookworm-slim
19+
20+ ENV NODE_ENV=production
21+ WORKDIR /usr/src/app
22+
23+ COPY --from=build /build .
24+
25+ # Use node user instead of root for security
26+ USER node
27+
28+ # Use exec form for better signal handling
29+ CMD ["node", "server.js"]
You can’t perform that action at this time.
0 commit comments