Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
Make admin ui work when volumes are mounted (#1266)
Browse files Browse the repository at this point in the history
* Make admin ui work when volumes are mounted

* Update changelog

* Fix path issue with hard refresh

* Update from code review

Co-authored-by: Paul Sanders <[email protected]>
  • Loading branch information
Paul Sanders and Paul Sanders authored Sep 7, 2022
1 parent 812435a commit 7ee7abe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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)

Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand All @@ -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
3 changes: 1 addition & 2 deletions clients/ops/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -71,4 +70,4 @@
"msw": {
"workerDirectory": "public"
}
}
}
11 changes: 8 additions & 3 deletions src/fidesops/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)):
Expand All @@ -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:
Expand Down

0 comments on commit 7ee7abe

Please sign in to comment.