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

Make admin ui work when volumes are mounted #1266

Merged
merged 5 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

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