There was no .dockerignore, so node_modules and build/ were copied into the build context on every build. Add one, install from the lockfile with npm ci, prune the dev dependencies out of the runtime layer and run as the node user.
19 lines
447 B
Docker
19 lines
447 B
Docker
# Build context: web-player/
|
|
FROM node:22-alpine AS build
|
|
WORKDIR /src
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci
|
|
COPY . .
|
|
RUN npm run build && npm prune --omit=dev
|
|
|
|
FROM node:22-alpine AS runtime
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
ENV PORT=3000
|
|
COPY --from=build /src/build ./build
|
|
COPY --from=build /src/node_modules ./node_modules
|
|
COPY --from=build /src/package.json ./package.json
|
|
USER node
|
|
EXPOSE 3000
|
|
CMD ["node", "build/index.js"]
|