thatmattlove / hyperglass

hyperglass is the network looking glass that tries to make the internet better.
https://hyperglass.dev
BSD 3-Clause Clear License
645 stars 102 forks source link

Avoid javascript rebuild in containerized environment #275

Closed M0NsTeRRR closed 4 months ago

M0NsTeRRR commented 4 months ago

Version

v2.0.4

Feature Details

To avoid rebuilding the application frontend, we need to mount a volume to /opt/hyperglass/hyperglass/ui/out. Unfortunately, Next.js tries to remove the folder instead of just deleting its content. An user shared a workaround: https://github.com/vercel/next.js/issues/59988#issuecomment-2181065230. With this workaround, for example by setting it to build/out, we can mount a volume into /opt/hyperglass/hyperglass/ui/build and let Next.js remove the build directory without issue.

HYPERGLASS_BUILD_ID environment variable must be saved in out to keep BUILD ID when the container restart.

hyperglass-1  | RuntimeError:
hyperglass-1  | Messages:
hyperglass-1  | Skipping validation of types
hyperglass-1  |    Linting ...
hyperglass-1  |    Creating an optimized production build ...
hyperglass-1  |  ✓ Compiled successfully
hyperglass-1  |    Collecting page data ...
hyperglass-1  |    Generating static pages (0/3) ...
hyperglass-1  |  ✓ Generating static pages (3/3)
hyperglass-1  |    Finalizing page optimization ...
hyperglass-1  |    Collecting build traces ...
hyperglass-1  | Errors:
hyperglass-1  | > Build error occurred
hyperglass-1  | [Error: EBUSY: resource busy or locked, rmdir
hyperglass-1  | '/opt/hyperglass/hyperglass/ui/out'] {
hyperglass-1  |   errno: -16,
hyperglass-1  |   code: 'EBUSY',
hyperglass-1  |   syscall: 'rmdir',
hyperglass-1  |   path: '/opt/hyperglass/hyperglass/ui/out'
hyperglass-1  | }

Feature Type

Change to Existing Functionality

Use Case

Avoiding the rebuilding of JavaScript files when it is not needed will increase application restart speed.

M0NsTeRRR commented 4 months ago

PR #276

The PR also contains a bug fix regarding hyperglass build id.

PS: I didn't wait for this feature to be accepted to implement it, as it's mandatory in my case. I will keep it in my fork if you don't want to implement it or merge my PR.

M0NsTeRRR commented 4 months ago

After digging more into it, I found that all content is copied to /static/ui. I will open a new issue as I found some bugs in the build ID system.