Skip to content

Commit 7a55116

Browse files
committed
fix: docker frontend build system
Signed-off-by: Ludovic Ortega <[email protected]>
1 parent 0b2fbb1 commit 7a55116

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

hyperglass/frontend/__init__.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ 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_dir = app_path / "static"
277+
build_id_dot_env_file = build_id_dot_env_dir / ".env"
276278
env_config = {}
277279

278280
ui_config_file = Path(__file__).parent.parent / "ui" / "hyperglass.json"
@@ -320,7 +322,7 @@ async def build_frontend( # noqa: C901
320322
write_favicon_formats(favicons.formats())
321323

322324
build_data = {
323-
"params": params.export_dict(),
325+
"params": sorted(params.export_dict()),
324326
"version": __version__,
325327
"package_json": package_json,
326328
}
@@ -333,17 +335,17 @@ async def build_frontend( # noqa: C901
333335

334336
# Read hard-coded environment file from last build. If build ID
335337
# 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)
338+
if not build_id_dot_env_dir.exists():
339+
build_id_dot_env_dir.mkdir()
340+
if build_id_dot_env_file.exists() and not force:
341+
env_data = dotenv_to_dict(build_id_dot_env_file)
338342
env_build_id = env_data.get("HYPERGLASS_BUILD_ID", "None")
339343
log.bind(id=env_build_id).debug("Previous build detected")
340344

341345
if env_build_id == build_id:
342346
log.debug("UI parameters unchanged since last build, skipping UI build...")
343347
return True
344348

345-
env_config.update({"HYPERGLASS_BUILD_ID": build_id})
346-
347349
dot_env_file.write_text("\n".join(f"{k}={v}" for k, v in env_config.items()))
348350
log.bind(path=str(dot_env_file)).debug("Wrote UI environment file")
349351

@@ -375,4 +377,7 @@ async def build_frontend( # noqa: C901
375377
params.web.theme.colors.black,
376378
)
377379

380+
build_id_dot_env_file.write_text(f"HYPERGLASS_BUILD_ID={build_id}")
381+
log.bind(path=str(build_id_dot_env_file)).debug("Wrote UI build environment file")
382+
378383
return True

0 commit comments

Comments
 (0)