diff --git a/CHANGELOG.md b/CHANGELOG.md index 152f09821..5e2a8c18c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ The types of changes are: * Allow worker to start up successfully for dev and dev_with_worker nox commands [#1250](https://github.com/ethyca/fidesops/pull/1250) * Fix for pytest-asyncio bug [#1260](https://github.com/ethyca/fidesops/pull/1260) * Fix download link in privacy center [#1264](https://github.com/ethyca/fidesops/pull/1264) +* Make admin ui work when volumes are mounted [#1266](https://github.com/ethyca/fidesops/pull/1266) ## [1.7.2](https://github.com/ethyca/fidesops/compare/1.7.1...1.7.2) diff --git a/Dockerfile b/Dockerfile index 2bb2240de..8cf54bb02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,8 +70,7 @@ ENV PYTHONUNBUFFERED=TRUE # Enable detection of running within Docker ENV RUNNING_IN_DOCKER=true -# Make a static files directory -RUN mkdir -p /fidesops/src/fidesops/ops/build/static/ +COPY --from=frontend /fidesops/clients/ops/admin-ui/out/ /admin_ui EXPOSE 8080 CMD [ "fidesops", "webserver" ] @@ -93,4 +92,4 @@ RUN python setup.py sdist RUN pip install dist/fidesops-*.tar.gz # Copy frontend build over -COPY --from=frontend /fidesops/clients/ops/admin-ui/out/ /fidesops/src/fidesops/ops/build/static/ +COPY --from=frontend /fidesops/clients/ops/admin-ui/out/ /admin_ui diff --git a/clients/ops/admin-ui/package.json b/clients/ops/admin-ui/package.json index 817da8321..5fd616816 100644 --- a/clients/ops/admin-ui/package.json +++ b/clients/ops/admin-ui/package.json @@ -17,7 +17,6 @@ "analyze:server": "cross-env BUNDLE_ANALYZE=server next build", "analyze:browser": "cross-env BUNDLE_ANALYZE=browser next build", "export": "next build && next export", - "copy-export": "rsync -a --delete out/ ../../../src/fidesops/ops/build/static/", "prod-export": "npm run export && npm run copy-export" }, "dependencies": { @@ -71,4 +70,4 @@ "msw": { "workerDirectory": "public" } -} \ No newline at end of file +} diff --git a/src/fidesops/main.py b/src/fidesops/main.py index f67a8539d..0030b0ff1 100644 --- a/src/fidesops/main.py +++ b/src/fidesops/main.py @@ -139,7 +139,7 @@ async def prepare_and_log_request( for handler in ExceptionHandlers.get_handlers(): app.add_exception_handler(FunctionalityNotConfigured, handler) -WEBAPP_DIRECTORY = Path("src/fidesops/ops/build/static") +WEBAPP_DIRECTORY = Path("/admin_ui") WEBAPP_INDEX = WEBAPP_DIRECTORY / "index.html" if config.admin_ui.enabled: @@ -155,7 +155,10 @@ def generate_route_file_map() -> None: nested_pattern_replacement = "[a-zA-Z10-9-_/]+" for filepath in WEBAPP_DIRECTORY.glob("**/*.html"): - relative_web_dir_path = str(filepath.relative_to(WEBAPP_DIRECTORY))[:-5] + # Strip off the file extenstion and convert to a string + relative_web_dir_path = str( + filepath.relative_to(WEBAPP_DIRECTORY).with_suffix("") + ) if filepath != WEBAPP_INDEX: path = None if re.search(exact_pattern, str(filepath)): @@ -173,7 +176,9 @@ def generate_route_file_map() -> None: rule = re.compile(r"^" + path) - route_file_map[rule] = FileResponse(str(filepath.relative_to("."))) + route_file_map[rule] = FileResponse( + f"{WEBAPP_DIRECTORY}/{str(filepath.relative_to(WEBAPP_DIRECTORY))}" + ) @app.on_event("startup") def check_if_admin_ui_index_exists() -> None: