[BUG]: Build system broken for production instances
See original GitHub issueDescribe 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:
- All dependencies needed for
NODE_ENV=production make run
to be present in packages.json, not some of them erroneously in devDependencies. - 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:
- Created 2 years ago
- Comments:21 (21 by maintainers)
Top GitHub Comments
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 issueAh 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 themake run
works:Build steps:
npm run webpack
npm run ts-compile
Then to run:
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 😃