Page MenuHomePhabricator

[keyserver] Run `source-nvm.sh` using `bash` in `Docker` container
ClosedPublic

Authored by abosh on Jul 1 2022, 6:05 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jun 23, 2:09 AM
Unknown Object (File)
Sat, Jun 22, 2:50 PM
Unknown Object (File)
Tue, Jun 18, 5:32 PM
Unknown Object (File)
Tue, Jun 18, 5:32 PM
Unknown Object (File)
Tue, Jun 18, 5:32 PM
Unknown Object (File)
Tue, Jun 18, 5:28 PM
Unknown Object (File)
Tue, Jun 18, 3:54 PM
Unknown Object (File)
Wed, Jun 12, 1:18 PM
Subscribers

Details

Summary

Relevant Linear issue with full context here. This diff modifies the Dockerfile in keyserver to execute source-nvm.sh in the environment specified by the shebang in source-nvm.sh instead of in the current environment of the container, which uses sh.

Read more here.

Thank you @atul for your help on this!

Test Plan

Ran the Docker keyserver build locally and it worked with no errors.

image.png (1×1 px, 424 KB)

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

keyserver/Dockerfile
97 ↗(On Diff #14101)

A minor change tacked onto this diff because the linter was complaining:

image.png (226×2 px, 98 KB)

abosh edited the summary of this revision. (Show Details)
abosh edited the test plan for this revision. (Show Details)

Makes sense

keyserver/Dockerfile
89 ↗(On Diff #14101)

Should we just do keyserver/bash/source-nvm.sh? Does the cd persist into the next command? (I think not)

This revision is now accepted and ready to land.Jul 2 2022, 6:52 PM
keyserver/Dockerfile
89 ↗(On Diff #14101)

Great question! It should be fine. From the Docker docs:

The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD instructions that follow it in the Dockerfile.

Thus, the next COPY command will not be affected by the cd here.

Read more here.

keyserver/Dockerfile
89

Based on this comment on D4429, I suspect that ./source-nvm.sh doesn't actually work to set the version of Node. But that's actually fine – we don't really rely on that here... we're running ./source-nvm.sh just to trigger nvm to download Node so it's cached in Docker. We rely on bash/run-prod.sh to handle calling nvm correctly.

The only effect here will be that commands like yarn workspace landing prod (Webpack) and yarn workspace keyserver prod-build (Babel, GeoIP download) run using Node 16.13 instead of 16.9. This is probably fine