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

build: make build should work while offline #21432

Closed
a-robinson opened this issue Jan 13, 2018 · 13 comments · Fixed by #27035
Closed

build: make build should work while offline #21432

a-robinson opened this issue Jan 13, 2018 · 13 comments · Fixed by #27035

Comments

@a-robinson
Copy link
Contributor

I tried running make build while offline today, and it failed due to the build/node-run.sh -C ./pkg/ui yarn install step of the build. I was able to work around it by ripping everything related to YARN_INSTALLED_TARGET out of the Makefile, and the resulting binary's UI worked just fine.

It's possible that it works normally and only needed the network because I changed between branches that had different versions of the UI code on them, but even so it'd be nice if there was an easier way to build cockroach while offline than having to do manual Makefile surgery.

@benesch
Copy link
Contributor

benesch commented Jan 15, 2018

You can run make buildshort to build a binary without a UI, which will skip running everything associated with building the UI, including running yarn install.

I'm also inclined to fold this into #14615. Whatever solution we come up with for avoiding hitting the Yarn registry in CI will likely make building offline possible, too.

@a-robinson
Copy link
Contributor Author

Ah, I wasn't aware of buildshort. Thanks!

@benesch
Copy link
Contributor

benesch commented Jan 16, 2018

Yeah, buildshort is a relatively recent development :)

@flokli
Copy link

flokli commented Feb 6, 2018

@benesch I also ran into this issue while trying to build current master to test for any follow-up bugs after #19472 (comment) .

My distro (NixOS) completely blocks network access during builds, for reproducibility. I'm sure this is also the case on other distributions as well.

Couldn't we move the yarn install task into a separate Makefile step? Most likely we could also get rid of all the yarn add hacks in there, as there already is a yarn.lock file available…

@couchand
Copy link
Contributor

couchand commented Feb 6, 2018

I don't think there's anything actionable to do here.

Regular users should usually be building from tarball, which includes the prebuilt bindata.go.

If a dev wants to build a binary without the network, they run make buildshort and don't build the UI. If you need the UI, just make sure to have built it once before while on the network, and the yarn cache should take care of you.

@benesch any reason we shouldn't just close this issue?

@flokli
Copy link

flokli commented Feb 7, 2018

@couchand So the yarn.lock being present in the repo doesn't yet solve the problem we're trying to fix near https://github.com/cockroachdb/cockroach/blob/master/Makefile#L324 ?

My idea about stripping this into separate build phases also goes out into the direction of distro packaging, as some packager build systems fetch source on their own and keep the build phase isolated from network access.

That's why I suggested a separate target to fetch external dependencies, and one to build everything assuming external deps are already there. The build target could then just execute those sequentially.

@benesch
Copy link
Contributor

benesch commented Feb 7, 2018 via email

@benesch
Copy link
Contributor

benesch commented Feb 14, 2018

Going to close based on the arguments presented by @couchand.

@benesch benesch closed this as completed Feb 14, 2018
@bdarnell
Copy link
Member

I think this is still worth doing something about (although not before 2.0). It's true that the source tarballs provide reproducible offline builds, but only at the go level. If I want to make a custom build with changed Go code, I can do that with the tarball. If I want to make a change to the UI, I need to pull in network resources to rebuild bindata.go (which makes it vulnerable to left-pad nonsense, etc).

I think the source tarballs should include the node_modules dependency subtree, so you have the option to rebuild the UI from them too (it's fine if they use a baked-in bindata.go by default).

@bdarnell bdarnell reopened this Feb 14, 2018
@benesch
Copy link
Contributor

benesch commented Feb 14, 2018

@bdarnell I think that’s covered by #14615.

@bdarnell
Copy link
Member

Yeah, this is a dupe of #14615 (although my point about including node_modules in source tarballs is kind of independent)

@couchand
Copy link
Contributor

couchand commented Feb 14, 2018

While I think the use case of someone wanting to pull the source tarball, modify the UI and rebuild without a network connection is awfully marginal, I'm not opposed to adding the node_modules directory to ARCHIVE_EXTRAS.

I don't think this is the solution to concerns about the left-pad problem (or should we be calling it the gobindata problem now?). Perhaps we should add node_modules to https://github.com/cockroachdb/vendored/, as that seems like it would actually solve it for mainline development, where it's much more critical.

@bdarnell
Copy link
Member

I don't think this is the solution to concerns about the left-pad problem (or should we be calling it the gobindata problem now?).

Fair enough, but we solve the gobindata problem with our vendor repo. Here we're talking about node_modules, so it's the left-pad problem :-P

Perhaps we should add node_modules to https://github.com/cockroachdb/vendored/, as that seems like it would actually solve it for mainline development, where it's much more critical.

I'm not sure I agree that it's more critical for mainline development than for release archives, but I agree that adding node_modules to the vendor repo would be a good move. I'm just making a cost/benefit argument. Adding the node_modules source to the tarball is (hopefully) trivial, while changing our js dependency workflow to incorporate the submodule is more of a pain.

benesch added a commit to benesch/cockroach that referenced this issue Jun 28, 2018
Vendor the NPM packages that our UI uses by checking them into a
submodule, github.com/cockroachdb/yarn-vendored. This prevents NPM or
Yarn registry flakiness from failing our CI builds, and also ensures
that a `git clone --recurse-submodules` is sufficient to build
CockroachDB offline.

The feature that enables this is Yarn's "offline mirror." The blog post
that introduced the feature also serves as its documentation:

    https://yarnpkg.com/blog/2016/11/24/offline-mirror/

To ensure the offline mirror is really used, we pass the '--offline'
flag to all Yarn invocations in the build system.

Fix cockroachdb#14615.
Really fix cockroachdb#21432.

Release note: None
benesch added a commit to benesch/cockroach that referenced this issue Jul 3, 2018
Vendor the NPM packages that our UI uses by checking them into a
submodule, github.com/cockroachdb/yarn-vendored. This prevents NPM or
Yarn registry flakiness from failing our CI builds, and also ensures
that a `git clone --recurse-submodules` is sufficient to build
CockroachDB offline.

The feature that enables this is Yarn's "offline mirror." The blog post
that introduced the feature also serves as its documentation:

    https://yarnpkg.com/blog/2016/11/24/offline-mirror/

To ensure the offline mirror is really used, we pass the '--offline'
flag to all Yarn invocations in the build system.

Fix cockroachdb#14615.
Really fix cockroachdb#21432.

Release note: None
craig bot pushed a commit that referenced this issue Jul 3, 2018
27035: ui: vendor NPM modules r=couchand,vilterp,bdarnell a=benesch

Vendor the NPM packages that our UI uses by checking them into a
submodule, [github.com/cockroachdb/yarn-vendored](https://github.com/cockroachdb/yarn-vendored). This prevents NPM or
Yarn registry flakiness from failing our CI builds, and also ensures
that a `git clone --recurse-submodules` is sufficient to build
CockroachDB offline.

The feature that enables this is Yarn's "offline mirror." The blog post
that introduced the feature also serves as its documentation:

    https://yarnpkg.com/blog/2016/11/24/offline-mirror/

To ensure the offline mirror is really used, we pass the '--offline'
flag to all Yarn invocations in the build system.

Fix #14615.
Really fix #21432.

Release note: None

Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
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 a pull request may close this issue.

5 participants