question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG]: Build system broken for production instances

See original GitHub issue

Describe the bug

Previously we ran make dist during a docker build, then make run when running the image.

As of #3269 make dist is gone. I tried instead using make prereqs then make run, but dist and run used to imply a production node env, so that no longer works, it gets us a dev instance instead which we do not want in our production. I then tried the same with NODE_ENV=production, but run tries to run webpack, which requires dev dependencies. As a result I have to run prereqs with a dev env and then run run with a production one, which is silly. Moreover, a plain make run (not messing with prereqs) on its own won’t work out of the box with NODE_ENV=production any more for the same reason.

I also am not a fan of webpack being run at run time. I would like to be able to do that up-front like used to happen, as that is a build step. The only reason it’s done at run time is to make dev setups less likely to have stale data, but that is not applicable to us, we start from a clean tree on every build.

I would therefore like two things:

  1. All dependencies needed for NODE_ENV=production make run to be present in packages.json, not some of them erroneously in devDependencies.
  2. A way (I don’t mind if I have to manually specify an extra make option or use a special target) to run webpack at build time and not at run time.

Steps to reproduce

N/A

Expected behavior

N/A

Reproduction link

Not applicable

Screenshots

Not applicable

Operating System

No response

Browser version

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:21 (21 by maintainers)

github_iconTop GitHub Comments

1reaction
jrtc27commented, Jan 24, 2022

Thanks; it’s non-critical now as I do have the workaround described in the bug report working, just documented with an XXX to move setting NODE_ENV back to before the make prereqs, pointing at this issue

0reactions
mattgodboltcommented, May 8, 2022

Ah got it, sorry! Yes!

If you look at how we package the site, it’s now somewhat simplified and hopefully can inspire a way forward for you: the etc/scripts/build-dist.sh runs all the commands needed to make two tarballs: one containing static files to be served (webpacked), and one containing the server-side code, transpiled. You don’t need to separate those two files (we have a CDN so ship them to separate locations), but essentially if you want to separate serving from webpacking etc, you can either use that script as a template, or look at how the make run works:

Build steps:

  • npm run webpack
  • npm run ts-compile

Then to run:

$ env NODE_ENV=production node -r esm ./out/dist/app.js --webpackContext ./out/webpack/static

or similar.

Please don’t hestitate to ask further questions; and/or if it would be more useful to have an interactive discussion about how best for CE to make itself externally packageable, let me know and we can use DMs/email/Discord/whatever works 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

9 techniques for fixing bugs in production - TechTarget
Bugs in software are bad. Bugs in live software are really bad. These nine techniques for fixing bugs in production empower software teams ......
Read more >
What Should We Do If We Found a Defect in Production ...
Finding a bug in a production environment may turn into a real problem for a tester who was responsible for testing it.
Read more >
The Irreproducibility of Bugs in Large-Scale Production Systems
The problem is found in the second step of the process: in large-scale production systems, the cycle breaks downs in the "reproduce the...
Read more >
[Support Guide] Frequently encountered problems during builds
In 99% of cases, it means we don't have permission to clone the repository you are trying to deploy. The usual cause for...
Read more >
Build Automation: Top 3 Problems and How to Solve Them
Complex builds are brittle – interactions between many different components often lead to manual error, broken builds and worse – builds that run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found