Skip to content
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

@uppy/companion: don't pin Yarn version in package.json #3347

Merged
merged 2 commits into from Dec 9, 2021

Conversation

aduh95
Copy link
Member

@aduh95 aduh95 commented Dec 7, 2021

The Dockerfile tries to build Companion standalone using some
trickery that is very much tied to npm logic, Yarn is not the fittest
tool here.

The Dockerfile tries to build Companion standalone using some
trickery that is very much tied to npm logic, Yarn is not the fittest
tool here.
@aduh95 aduh95 requested a review from mifi December 7, 2021 08:58
Copy link
Contributor

@mifi mifi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this trickery you're referring to? I just tried locally on my machine, and even though I have installed uppy with corepack yarn install, I was able to run npm run build successfully and even corepack yarn run build works for me. I think we should strive for equal environments in development and prod (if we use yarn in dev, we should use yarn in prod too)

@aduh95
Copy link
Member Author

aduh95 commented Dec 8, 2021

What's this trickery you're referring to?

ADD package.json package-*.json yarn.* /tmp/
RUN cd /tmp && apk --update add --virtual native-dep \
make gcc g++ python3 libgcc libstdc++ git && \
corepack yarn install && \
apk del native-dep
RUN mkdir -p /app && cd /app && ln -nfs /tmp/node_modules
RUN apk add bash
COPY . /app
ENV PATH "${PATH}:/app/node_modules/.bin"

@mifi
Copy link
Contributor

mifi commented Dec 8, 2021

Is there any error? It’s not obvious to me why that code doesnt work with corepack yarn install but works with npm install

@aduh95
Copy link
Member Author

aduh95 commented Dec 8, 2021

I think we should strive for equal environments in development and prod

OK but where's the limit? Should all Uppy devs be forced to use Docker so we can have the same environment as the prod? The Dockerfile is using apk, which I don't have in my env, and I honestly don't see this as a problem.

if we use yarn in dev, we should use yarn in prod too

Why not use both? I think all Uppy devs have both npm and yarn on their path, so it's not an issue of a different environment, it's simply different tools.
Anyway, I'm not against using Yarn here, I tried and failed so I'm no longer interested in making this happen. I believe rolling back to npm makes sense here, and has the least risk associated with it.

why that code doesnt work with corepack yarn install but works with npm install

Yarn by default uses PnP instead of node_modules, we have to specify in its config file to use the node_modules linker, and we don't copy that config file into the docker container. Also, corepack yarn build will refuse to run if it can't find a yarn.lock file, while npm run build tries to run the script without any check. I don't know why it was decided to use a /tmp directory here (I asked @kiloreux but they didn't know/remember), and I'm too afraid to touch it at this point.

If you want this script to use Yarn, you'd need to refactor the Dockerfile so it pulls up the whole monorepo and install all the deps from all the packages (unless you can find a way to ask Yarn to install only a subset of those, not sure).

@mifi
Copy link
Contributor

mifi commented Dec 8, 2021

I agree that using yarn npm run build vs npm run build doesn't make any difference, I was thinking more about the differences between yarn install vs npm install.

OK but where's the limit? Should all Uppy devs be forced to use Docker so we can have the same environment as the prod? The Dockerfile is using apk, which I don't have in my env, and I honestly don't see this as a problem.

Absolutely, i agree that we shouldn't have to run companion in docker or with apk in our dev environment. but I thought that things like using a supported node.js version and the same package manager as production for installing node_modules is more important.

Why not use both? I think all Uppy devs have both npm and yarn on their path, so it's not an issue of a different environment, it's simply different tools.

Drawbacks I see with using two different package managers for node_modules:

  • lockfile is not respected, so docker will have a different set of node_modules dependencies than dev
    • although maybe we can work around by converting yarn.lock to package-lock.json in the docker build script? need to research how to do that
  • I thought yarn and npm had some differences in how they resolve dependencies when it comes to directory structure and deduplication, and this may affect some packages that are sensitive to the node_modules structure. maybe this has changed in recent versions though...

Yarn by default uses PnP instead of node_modules, we have to specify in its config file to use the node_modules linker, and we don't copy that config file into the docker container.

I agree we should strive to use PnP as long as it's possible. I know some packages don't support PnP but we haven't hit that issue yet, so it makes more sense to rewrite the dockerfile to support PnP than to turn off PnP.

If you want this script to use Yarn, you'd need to refactor the Dockerfile so it pulls up the whole monorepo and install all the deps from all the packages (unless you can find a way to ask Yarn to install only a subset of those, not sure).

I think we can use yarn workspaces focus to install only one workspace's dependencies. I've used it in other projects with success. (non-PnP project but I believe it works for PnP too.)

I can see why nobody wants to do the job of rewriting the dockerfile, so maybe we should just merge this and raise a new TODO issue for rewriting it to support yarn. what do you think?

@aduh95
Copy link
Member Author

aduh95 commented Dec 8, 2021

  • lockfile is not respected, so docker will have a different set of node_modules dependencies than dev

AFAIU it was already the case, the Dockerfile was not getting the lock file when we were using npm. That doesn't mean we should keep it this way, but at least it's not new with this very PR.

I agree we should strive to use PnP as long as it's possible. I know some packages don't support PnP but we haven't hit that issue yet, so it makes more sense to rewrite the dockerfile to support PnP than to turn off PnP.

We are currently not using PnP, it's already disabled. If we were, npm run … commands would not work. We could decide to switch to it, but that's a discussion for another time.

I can see why nobody wants to do the job of rewriting the dockerfile, so maybe we should just merge this and raise a new TODO issue for rewriting it to support yarn. what do you think?

That's fine by me; maybe I could add a TODO comment to save ourselves from an issue, wdyt?

Copy link
Member Author

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docker deploys are being fixed in #3355, this PR now focuses only on fixing #3356.

packages/@uppy/companion/Dockerfile Outdated Show resolved Hide resolved
packages/@uppy/companion/Dockerfile Outdated Show resolved Hide resolved
@aduh95 aduh95 changed the title @uppy/companion: use npm when building in Dockerfile @uppy/companion: don't pin Yarn version in package.json Dec 9, 2021
@aduh95 aduh95 merged commit 9c7b17e into transloadit:main Dec 9, 2021
@aduh95 aduh95 deleted the fix-companion-deploy branch December 9, 2021 15:52
@github-actions github-actions bot mentioned this pull request Dec 9, 2021
github-actions bot added a commit that referenced this pull request Dec 9, 2021
| Package           | Version | Package           | Version |
| ----------------- | ------- | ----------------- | ------- |
| @uppy/angular     |   0.2.7 | @uppy/store-redux |   2.0.3 |
| @uppy/audio       |   0.2.1 | @uppy/svelte      |   1.0.6 |
| @uppy/aws-s3      |   2.0.7 | @uppy/vue         |   0.4.4 |
| @uppy/companion   |   3.1.3 | @uppy/xhr-upload  |   2.0.7 |
| @uppy/core        |   2.1.4 | @uppy/robodog     |   2.1.5 |
| @uppy/dashboard   |   2.1.3 | uppy              |   2.3.1 |
| @uppy/locales     |   2.0.5 |                   |         |

- meta: update npm deps (Antoine du Hamel / #3352)
- @uppy/companion: fix Dockerfile and deploy automation (Mikael Finstad / #3355)
- @uppy/companion: don’t pin Yarn version in `package.json` (Antoine du Hamel / #3347)
- @uppy/aws-s3,@uppy/core,@uppy/dashboard,@uppy/store-redux,@uppy/xhr-upload: deps: use `nanoid/non-secure` to workaround react-native limitation (Antoine du Hamel / #3350)
- @uppy/audio: showRecordingLength option was removed, always clearInterval (Artur Paikin / #3351)
- meta: drop `stringify-object` dependency to generate locales (Antoine du Hamel / #3344)
- meta: add release automations (Antoine du Hamel / #3304)
HeavenFox pushed a commit to docsend/uppy that referenced this pull request Jun 27, 2023
HeavenFox pushed a commit to docsend/uppy that referenced this pull request Jun 27, 2023
| Package           | Version | Package           | Version |
| ----------------- | ------- | ----------------- | ------- |
| @uppy/angular     |   0.2.7 | @uppy/store-redux |   2.0.3 |
| @uppy/audio       |   0.2.1 | @uppy/svelte      |   1.0.6 |
| @uppy/aws-s3      |   2.0.7 | @uppy/vue         |   0.4.4 |
| @uppy/companion   |   3.1.3 | @uppy/xhr-upload  |   2.0.7 |
| @uppy/core        |   2.1.4 | @uppy/robodog     |   2.1.5 |
| @uppy/dashboard   |   2.1.3 | uppy              |   2.3.1 |
| @uppy/locales     |   2.0.5 |                   |         |

- meta: update npm deps (Antoine du Hamel / transloadit#3352)
- @uppy/companion: fix Dockerfile and deploy automation (Mikael Finstad / transloadit#3355)
- @uppy/companion: don’t pin Yarn version in `package.json` (Antoine du Hamel / transloadit#3347)
- @uppy/aws-s3,@uppy/core,@uppy/dashboard,@uppy/store-redux,@uppy/xhr-upload: deps: use `nanoid/non-secure` to workaround react-native limitation (Antoine du Hamel / transloadit#3350)
- @uppy/audio: showRecordingLength option was removed, always clearInterval (Artur Paikin / transloadit#3351)
- meta: drop `stringify-object` dependency to generate locales (Antoine du Hamel / transloadit#3344)
- meta: add release automations (Antoine du Hamel / transloadit#3304)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants