-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Integrate FastHTML replacing FastAPI and React
This introduces a major change by replacing the FastAPI backend and React frontend with FastHTML. The integration involves reusing existing code where possible, but also includes significant rewrites that affect the application's behavior. This update aims to enhance performance and streamline the development process. This commit also introduces project management tool which replaces the Makefile with a Python CLI tool. The tool manages the project, including building the Docker image, running the app in a container, and running the app locally. The tool also builds the Tailwind CSS stylesheet. The app always runs with hot template reloading enabled. In development mode, it also runs with hot code reloading. After cloning the project, one can get further information by running: ```bash cme -h cme run -h cme build -h ``` Co-authored-by: Martin Lehmann <[email protected]>
- Loading branch information
1 parent
649ef5f
commit 2173540
Showing
136 changed files
with
8,863 additions
and
12,462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
static/css/main*.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
static/css/main*.min.js | ||
static/js/plotly*.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"printWidth": 79, | ||
"tabWidth": 2 | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,84 @@ | ||
# Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Build frontend | ||
FROM node:20 AS build-frontend | ||
WORKDIR /app | ||
COPY frontend/package*.json ./ | ||
RUN npm install | ||
COPY frontend/ ./ | ||
RUN npm run build | ||
|
||
# Build backend | ||
FROM python:3.12-slim-bookworm | ||
WORKDIR /app | ||
|
||
USER root | ||
|
||
RUN apt-get update && \ | ||
apt-get install --yes --no-install-recommends \ | ||
git \ | ||
git-lfs \ | ||
libgirepository1.0-dev \ | ||
libcairo2-dev \ | ||
gir1.2-pango-1.0 \ | ||
graphviz \ | ||
nodejs \ | ||
npm && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY ./capella_model_explorer ./capella_model_explorer | ||
COPY ./pyproject.toml ./ | ||
COPY ./.git ./.git | ||
|
||
RUN pip install --no-cache-dir . | ||
COPY --from=build-frontend /app/dist/ ./frontend/dist/ | ||
|
||
# Expose the port the app runs in | ||
WORKDIR /app | ||
ENV HOME=/home | ||
ENV PATH=$HOME/.local/bin:$PATH | ||
ENV MODEL_ENTRYPOINT=/model | ||
# Expose the port the app runs on | ||
EXPOSE 8000 | ||
|
||
COPY ./templates /views | ||
|
||
ENV HOME=/home | ||
# install system pkgs {{{ | ||
RUN apt-get update && \ | ||
apt-get install --yes --no-install-recommends \ | ||
curl \ | ||
git \ | ||
git-lfs \ | ||
gir1.2-pango-1.0 \ | ||
graphviz \ | ||
libcairo2-dev \ | ||
libgirepository1.0-dev \ | ||
npm && \ | ||
apt-get autoremove --yes && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
# }}} | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
# copy files {{{ | ||
COPY capella_model_explorer capella_model_explorer | ||
COPY static static | ||
COPY templates templates | ||
COPY pyproject.toml ./ | ||
COPY .git .git | ||
COPY package*.json ./ | ||
# copy entrypoint.sh to root: | ||
COPY entrypoint.sh / | ||
RUN chmod +x /entrypoint.sh | ||
ENV MODEL_ENTRYPOINT=/model | ||
RUN chmod -R 777 ./frontend/dist/ | ||
# }}} | ||
|
||
# Run script to get software version | ||
ENV MODE=production | ||
COPY frontend/fetch-version.py ./frontend/ | ||
RUN python frontend/fetch-version.py && \ | ||
python -c "from capellambse_context_diagrams import install_elk; install_elk()" | ||
# misc setup {{{ | ||
RUN git config --global --add safe.directory /model && \ | ||
git config --global --add safe.directory /model/.git && \ | ||
chmod -R 777 /app && \ | ||
chmod -R 777 /home | ||
# }}} | ||
|
||
# Run as non-root user per default | ||
RUN git config --global --add safe.directory /model && \ | ||
git config --global --add safe.directory /model/.git && \ | ||
chmod -R 777 /home | ||
USER 1000 | ||
|
||
# install uv {{{ | ||
RUN curl -Lo /tmp/install.sh https://astral.sh/uv/install.sh && \ | ||
chmod +x /tmp/install.sh && \ | ||
UV_NO_MODIFY_PATH=1 sh /tmp/install.sh && \ | ||
rm /tmp/install.sh | ||
# }}} | ||
|
||
# install app incl. its cli and install elk.js {{{ | ||
RUN uv venv && \ | ||
# install app | ||
uv pip install --no-cache-dir . && \ | ||
# Install elk.js automatically into a persistent local cache directory | ||
# in order to prepare the elk.js execution environment ahead of time. | ||
uv run python3 -c "from capellambse_context_diagrams import install_elk; install_elk()" | ||
# }}} | ||
|
||
# install Nodep kgs and build the CSS {{{ | ||
RUN npm clean-install && uv run python3 -m capella_model_explorer build css | ||
# }}} | ||
|
||
# clean up as root {{{ | ||
USER root | ||
RUN ln -s /home/.local/bin/uv /usr/local/bin && \ | ||
apt-get purge --remove --yes curl npm && \ | ||
apt-get autoremove --yes && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* \ | ||
rm -rf node_modules | ||
# }}} | ||
|
||
# Back to non-root user | ||
USER 1000 | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] |
Oops, something went wrong.