Building production-ready artifacts from pnpm monorepo #4478
Replies: 2 comments
-
It sounds like this should be possible to to if you'd use a tool lite Turborepo and its Tasks. There you could define which dependency tasks another one is dependent one. |
Beta Was this translation helpful? Give feedback.
-
I'm not 100% if this is what you're asking but have you looked at Some resources:
FROM node:lts-alpine3.19 AS base
RUN corepack enable
WORKDIR /usr/src/app
COPY pnpm-lock.yaml .
RUN pnpm fetch
COPY . .
RUN pnpm i --offline --frozen-lockfile
RUN pnpm build
RUN pnpm -F=foo --prod deploy /myapp/foo
RUN pnpm -F=bar --prod deploy /myapp/bar
# Use `foo` or `bar` as a target when deploying
FROM node:lts-alpine3.19 AS foo
COPY --from=base /myapp/foo /myapp/foo
WORKDIR /myapp/foo
CMD node build/server.js
FROM node:lts-alpine3.19 AS bar
COPY --from=base /myapp/bar /myapp/bar
WORKDIR /myapp/bar
CMD node build/server.js |
Beta Was this translation helpful? Give feedback.
-
Hey,
when I am working on my local machine all the symlinks produced by pnpm for dependencies in every workspace package are simply amazing. A lot of time and storage space is saved. Unfortunately, almost every package in production environment needs to be built and served separately as a standalone container image. I would prefer to avoid adding all dependencies and the code of all the packages to every single artifact built per package in the workspace. Unfortunately, no matter what settings I am using, there are always some packages either missing or symbolically linked to directories outside the given package. Can somebody, please, guide me on how to build standalone production artifacts on a per package basis?
my monorepo has the following structure:
Both service1 and service2 are using package 'shared' as a dependency.
I would like to install dependencies and build package
shared
first, then install dependencies of service1 and clone the dist folder of the shared directory into node_modules/@myorg/shared in service1 package. This way directory service1 alone could be cloned to a docker image and become a standalone app. The same goes for service2. Is this possible? If that's a bad practice, what should I research instead?Beta Was this translation helpful? Give feedback.
All reactions