New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A deploy command #4378
Comments
OK, so I think this workaround works now. Let's say the package to be deployed is at Create the next module.exports = {
hooks: {
readPackage (pkg) {
pkg.dependenciesMeta = pkg.dependenciesMeta || {}
for (const [depName, depVersion] of Object.entries(pkg.dependencies)) {
if (depVersion.startsWith('workspace:')) {
pkg.dependenciesMeta[depName] = {
injected: true
}
}
}
return pkg
}
}
} Run:
Your project will have all the needed dependencies in its node_modules folder. |
How about specify a deploy folder and copy everything needed to this folder. Like
After run deploy package a
Under deploy_folder, just run |
In order for this to work, I need to make this breaking change in pnpm v7: #4469 |
it would need additional development. My solution that I described in the comment above (#4378 (comment)) doesn't require additional development. It already works by using the injected deps features. So the projects are copied automatically by pnpm into the node_modules of the deployed app. |
So I tried this and it doesn't seem to work. I'm using pnpm 7.0.1. |
Came across this issue and we're running into the same issue over at Disney Streaming, we deploy our applications in Docker containers. During CI having multiple node_modules folders becomes cumbersome and having a single source of truth for our deployable's dependencies would be amazing. I also came across this package but I'm getting the following error when trying to use it: PnpmError: Cannot resolve workspace protocol of dependency "<dependencyName>" because this dependency is not installed. Try running "pnpm install". When trying to use this workaround when running ERR_PNPM_OUTDATED_LOCKFILE Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up-to-date with package.json
Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile" Ideally, the versions of dependencies in our deployable match those that we're using locally. I'm able to pass |
@AlecOrtega Have you tried using @Madvinking 's https://github.com/Madvinking/pnpm-isolate-workspace |
@maschwenk I have not! I'll give that a try as well |
Hi there, before creating another ticket, I want to know if this is related. I have a pnpm-workspace project with a UI package library and a Nuxt app consuming it, When deploying to Netlify I get this error when I build the Nuxt app:
I also get something similar if I try to run some Github Actions, is the Thanks in advance |
I don't know, try node-linker=hoisted |
Greatly appreciate the provided I also like the isolated deploy folder approach which is kind of similar to how rush handles this with |
🚢 7.4.0-3 |
We need to optimize the dependancies with the deploy command only to have dependancies of the package pruned. Needs to remove all other dependancies and dev dependancies. |
To exclude dev dep, use
|
What is the recommended way to deploy a monorepo with private workspace packages to a Docker image? The packages in
After deploying
|
inject the private stuff: https://pnpm.io/package_json#dependenciesmetainjected |
Hey, is there any example demo the usage? I'm new to docker, all my docker images are same size. I think apps/gateway/Dockerfile FROM node:18-alpine as builder
RUN apk update
RUN apk add git
RUN corepack enable && corepack prepare pnpm@7.7.0 --activate
WORKDIR /app
COPY . .
RUN --mount=type=cache,target=/.pnpm-store \
mkdir out && \
cp package.json .swcrc turbo.json pnpm-workspace.yaml pnpm-lock.yaml tsconfig.json out/ && \
cd out && \
pnpm install && \
pnpm exec turbo run build --filter=gateway && \
pnpm prune --prod
FROM node:18-alpine as app
ENV NODE_ENV=production
COPY --chown=node:node --from=builder /app/out .
WORKDIR /app/apps/gateway
USER node
CMD TZ=UTC node --experimental-specifier-resolution=node dist/main.js docke-compose.yml version: "3.8"
services:
gateway:
build:
dockerfile: ./apps/gateway/Dockerfile
restart: on-failure:3
volumes:
- .:/app
ports:
- '5001:5001'
networks:
- app-network
hostname: gateway
identity:
build:
dockerfile: ./apps/service-identity/Dockerfile
restart: on-failure:3
hostname: microservice-identity
volumes:
- .:/app
environment:
- PORT=${GRPC_IDENTITY_PORT}
networks:
- app-network
networks:
app-network:
driver: bridge |
Was able to have working Docker containers with :
Without that, I've never been able to retrieve dependencies from dependencies (deep deps). |
@zkochan Is there some way to do this without having to specify all the internal packages in I guess also we only want this to happen during docker builds that use |
Any progress on a solution that bundles only the necessary modules? |
Describe the user story
I want to deploy a project from a workspace that dependends on other projects from the workspace
Describe the solution you'd like
pnpm should copy any dependencies of the project to the project is being deployed and install its node_modules
Related issues:
It is probably best to implement it first as a separate tool. The easiest solution might be to copy any dependents of the project to some subfolder inside the deployed project, create a new workspace and run install.
For example. There is a workspace where b and c are dependencies of a.
The deploy command will copy b and c to
a/dependencies
, create apnpm-workspace.yaml
inside a and run install:Alternative solution
We may use the injected dependencies feature to inject all the workspace dependencies of the project. Run install only for the selected project and set the virtual store directory to be inside the project.
The text was updated successfully, but these errors were encountered: