Skip to content

Commit e002594

Browse files
committed
feat: allow javascript caching in docker environment
Signed-off-by: Ludovic Ortega <[email protected]>
1 parent 0b2fbb1 commit e002594

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

.dockerignore

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ hyperglass/ui/.env*
66
hyperglass.json
77
custom.*[js, html]
88
.next
9-
out/
109
fonts/
1110
__pycache__
1211
.python-version

biome.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"node_modules",
99
"dist",
1010
".next/",
11-
"out/",
11+
"build/",
1212
"favicon-formats.ts",
1313
"custom.*[js, html]",
1414
"hyperglass.json"

hyperglass/frontend/__init__.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async def build_ui(app_path: Path):
9999

100100
ui_dir = Path(__file__).parent.parent / "ui"
101101
build_dir = app_path / "static" / "ui"
102-
out_dir = ui_dir / "out"
102+
out_dir = ui_dir / "build" / "out"
103103

104104
build_command = "node_modules/.bin/next build"
105105

@@ -273,6 +273,7 @@ async def build_frontend( # noqa: C901
273273
# Create temporary file. json file extension is added for easy
274274
# webpack JSON parsing.
275275
dot_env_file = Path(__file__).parent.parent / "ui" / ".env"
276+
build_id_dot_env_file = Path(__file__).parent.parent / "ui" / "build" / ".env"
276277
env_config = {}
277278

278279
ui_config_file = Path(__file__).parent.parent / "ui" / "hyperglass.json"
@@ -320,7 +321,7 @@ async def build_frontend( # noqa: C901
320321
write_favicon_formats(favicons.formats())
321322

322323
build_data = {
323-
"params": params.export_dict(),
324+
"params": sorted(params.export_dict()),
324325
"version": __version__,
325326
"package_json": package_json,
326327
}
@@ -333,19 +334,19 @@ async def build_frontend( # noqa: C901
333334

334335
# Read hard-coded environment file from last build. If build ID
335336
# matches this build's ID, don't run a new build.
336-
if dot_env_file.exists() and not force:
337-
env_data = dotenv_to_dict(dot_env_file)
337+
if build_id_dot_env_file.exists() and not force:
338+
env_data = dotenv_to_dict(build_id_dot_env_file)
338339
env_build_id = env_data.get("HYPERGLASS_BUILD_ID", "None")
339340
log.bind(id=env_build_id).debug("Previous build detected")
340341

341342
if env_build_id == build_id:
342343
log.debug("UI parameters unchanged since last build, skipping UI build...")
343344
return True
344345

345-
env_config.update({"HYPERGLASS_BUILD_ID": build_id})
346-
347346
dot_env_file.write_text("\n".join(f"{k}={v}" for k, v in env_config.items()))
348347
log.bind(path=str(dot_env_file)).debug("Wrote UI environment file")
348+
build_id_dot_env_file.write_text(f"HYPERGLASS_BUILD_ID={build_id}")
349+
log.bind(path=str(build_id_dot_env_file)).debug("Wrote UI build environment file")
349350

350351
# Initiate Next.JS export process.
351352
if any((not dev_mode, force, full)):

hyperglass/ui/next.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const nextConfig = {
99
},
1010
swcMinify: true,
1111
productionBrowserSourceMaps: true,
12+
distDir: "build/out",
1213
};
1314

1415
if (process.env.NODE_ENV === 'production') {

0 commit comments

Comments
 (0)