diff --git a/.dockerignore b/.dockerignore index 0f262bb7c..95c1d6ae4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,6 @@ env helm -passbook-ui static +htmlcov *.env.yml -**/node_modules +node_modules/** diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 726220f26..19135cadc 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,7 +9,7 @@ updates: assignees: - BeryJu - package-ecosystem: npm - directory: "/passbook/static/static" + directory: "/web" schedule: interval: daily time: "04:00" diff --git a/Makefile b/Makefile index fa2af4009..3356d25e2 100644 --- a/Makefile +++ b/Makefile @@ -31,3 +31,8 @@ local-stack: docker build -t beryju/passbook:testng . docker-compose up -d docker-compose run --rm server migrate + +build-static: + docker-compose -f scripts/ci.docker-compose.yml up -d + docker build -t beryju/passbook-static -f static.Dockerfile --network=scripts_default . + docker-compose -f scripts/ci.docker-compose.yml down -v diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0569a21fb..dc5a1e8a2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -272,7 +272,7 @@ stages: displayName: Build static files for e2e inputs: script: | - cd passbook/static/static + cd web npm i npm run build - task: CmdLine@2 diff --git a/passbook/root/settings.py b/passbook/root/settings.py index d454bf05c..3039f371e 100644 --- a/passbook/root/settings.py +++ b/passbook/root/settings.py @@ -48,12 +48,9 @@ LOGGER = structlog.get_logger() # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) STATIC_ROOT = BASE_DIR + "/static" +STATICFILES_DIRS = [BASE_DIR + "/web"] MEDIA_ROOT = BASE_DIR + "/media" -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = CONFIG.y( "secret_key", "9$@r!d^1^jrn#fk#1#@ks#9&i$^s#1)_13%$rwjrhd=e8jfi_s" ) # noqa Debug @@ -124,7 +121,6 @@ INSTALLED_APPS = [ "passbook.stages.otp_time.apps.PassbookStageOTPTimeConfig", "passbook.stages.otp_validate.apps.PassbookStageOTPValidateConfig", "passbook.stages.password.apps.PassbookStagePasswordConfig", - "passbook.static.apps.PassbookStaticConfig", "rest_framework", "django_filters", "drf_yasg2", diff --git a/passbook/root/urls.py b/passbook/root/urls.py index 1f919c0d7..1cb733aaa 100644 --- a/passbook/root/urls.py +++ b/passbook/root/urls.py @@ -65,6 +65,7 @@ if settings.DEBUG: [ path("-/debug/", include(debug_toolbar.urls)), ] + + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + urlpatterns ) diff --git a/passbook/static/__init__.py b/passbook/static/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/passbook/static/apps.py b/passbook/static/apps.py deleted file mode 100644 index e866c5fbc..000000000 --- a/passbook/static/apps.py +++ /dev/null @@ -1,10 +0,0 @@ -"""passbook static app config""" -from django.apps import AppConfig - - -class PassbookStaticConfig(AppConfig): - """passbook static app config""" - - name = "passbook.static" - label = "passbook_static" - verbose_name = "passbook Static" diff --git a/static.Dockerfile b/static.Dockerfile index bcfafd899..13e3b7cc9 100644 --- a/static.Dockerfile +++ b/static.Dockerfile @@ -34,21 +34,18 @@ ENV PASSBOOK_REDIS__HOST=redis ENV PASSBOOK_POSTGRESQL__USER=passbook # CI Password, same as in .github/workflows/ci.yml ENV PASSBOOK_POSTGRESQL__PASSWORD="EK-5jnKfjrGRm<77" -RUN ./manage.py collectstatic --no-input +RUN mkdir -p /app/web && \ + ./manage.py collectstatic --no-input FROM node as npm-builder -COPY --from=static-build /app/static/src /static/src -COPY --from=static-build /app/static/rollup.config.js /static/rollup.config.js -COPY --from=static-build /app/static/tsconfig.json /static/tsconfig.json -COPY --from=static-build /app/static/package.json /static/package.json -COPY --from=static-build /app/static/package-lock.json /static/package-lock.json +COPY ./web /static/ RUN cd /static && npm i && npm run build FROM nginx COPY --from=static-build /app/static /usr/share/nginx/html/static -COPY --from=static-build /app/static/robots.txt /usr/share/nginx/html/robots.txt +COPY --from=npm-builder /static/robots.txt /usr/share/nginx/html/robots.txt COPY --from=npm-builder /static/node_modules /usr/share/nginx/html/static/node_modules COPY --from=npm-builder /static/dist/* /usr/share/nginx/html/static/dist/ diff --git a/passbook/static/static/.gitignore b/web/.gitignore similarity index 100% rename from passbook/static/static/.gitignore rename to web/.gitignore diff --git a/passbook/static/static/.prettierignore b/web/.prettierignore similarity index 100% rename from passbook/static/static/.prettierignore rename to web/.prettierignore diff --git a/passbook/static/static/.prettierrc.json b/web/.prettierrc.json similarity index 100% rename from passbook/static/static/.prettierrc.json rename to web/.prettierrc.json diff --git a/passbook/static/static/dist/assets/fonts/DINEngschriftStd.woff b/web/dist/assets/fonts/DINEngschriftStd.woff similarity index 100% rename from passbook/static/static/dist/assets/fonts/DINEngschriftStd.woff rename to web/dist/assets/fonts/DINEngschriftStd.woff diff --git a/passbook/static/static/dist/assets/fonts/DINEngschriftStd.woff2 b/web/dist/assets/fonts/DINEngschriftStd.woff2 similarity index 100% rename from passbook/static/static/dist/assets/fonts/DINEngschriftStd.woff2 rename to web/dist/assets/fonts/DINEngschriftStd.woff2 diff --git a/passbook/static/static/dist/assets/images/flow_background.jpg b/web/dist/assets/images/flow_background.jpg similarity index 100% rename from passbook/static/static/dist/assets/images/flow_background.jpg rename to web/dist/assets/images/flow_background.jpg diff --git a/passbook/static/static/dist/assets/images/logo.png b/web/dist/assets/images/logo.png similarity index 100% rename from passbook/static/static/dist/assets/images/logo.png rename to web/dist/assets/images/logo.png diff --git a/passbook/static/static/dist/assets/images/logo.svg b/web/dist/assets/images/logo.svg similarity index 100% rename from passbook/static/static/dist/assets/images/logo.svg rename to web/dist/assets/images/logo.svg diff --git a/passbook/static/static/dist/assets/images/user-default.png b/web/dist/assets/images/user-default.png similarity index 100% rename from passbook/static/static/dist/assets/images/user-default.png rename to web/dist/assets/images/user-default.png diff --git a/passbook/static/static/dist/index.html b/web/dist/index.html similarity index 100% rename from passbook/static/static/dist/index.html rename to web/dist/index.html diff --git a/passbook/static/static/dist/main.js b/web/dist/main.js similarity index 100% rename from passbook/static/static/dist/main.js rename to web/dist/main.js diff --git a/passbook/static/static/dist/main.js.map b/web/dist/main.js.map similarity index 100% rename from passbook/static/static/dist/main.js.map rename to web/dist/main.js.map diff --git a/passbook/static/static/dist/passbook.css b/web/dist/passbook.css similarity index 100% rename from passbook/static/static/dist/passbook.css rename to web/dist/passbook.css diff --git a/passbook/static/static/package-lock.json b/web/package-lock.json similarity index 100% rename from passbook/static/static/package-lock.json rename to web/package-lock.json diff --git a/passbook/static/static/package.json b/web/package.json similarity index 100% rename from passbook/static/static/package.json rename to web/package.json diff --git a/passbook/static/static/passbook/sources/azure-ad.svg b/web/passbook/sources/azure-ad.svg similarity index 100% rename from passbook/static/static/passbook/sources/azure-ad.svg rename to web/passbook/sources/azure-ad.svg diff --git a/passbook/static/static/passbook/sources/discord.svg b/web/passbook/sources/discord.svg similarity index 100% rename from passbook/static/static/passbook/sources/discord.svg rename to web/passbook/sources/discord.svg diff --git a/passbook/static/static/passbook/sources/dropbox.svg b/web/passbook/sources/dropbox.svg similarity index 100% rename from passbook/static/static/passbook/sources/dropbox.svg rename to web/passbook/sources/dropbox.svg diff --git a/passbook/static/static/passbook/sources/facebook.svg b/web/passbook/sources/facebook.svg similarity index 100% rename from passbook/static/static/passbook/sources/facebook.svg rename to web/passbook/sources/facebook.svg diff --git a/passbook/static/static/passbook/sources/github.svg b/web/passbook/sources/github.svg similarity index 100% rename from passbook/static/static/passbook/sources/github.svg rename to web/passbook/sources/github.svg diff --git a/passbook/static/static/passbook/sources/gitlab.svg b/web/passbook/sources/gitlab.svg similarity index 100% rename from passbook/static/static/passbook/sources/gitlab.svg rename to web/passbook/sources/gitlab.svg diff --git a/passbook/static/static/passbook/sources/google.svg b/web/passbook/sources/google.svg similarity index 100% rename from passbook/static/static/passbook/sources/google.svg rename to web/passbook/sources/google.svg diff --git a/passbook/static/static/passbook/sources/openid-connect.svg b/web/passbook/sources/openid-connect.svg similarity index 100% rename from passbook/static/static/passbook/sources/openid-connect.svg rename to web/passbook/sources/openid-connect.svg diff --git a/passbook/static/static/passbook/sources/twitter.svg b/web/passbook/sources/twitter.svg similarity index 100% rename from passbook/static/static/passbook/sources/twitter.svg rename to web/passbook/sources/twitter.svg diff --git a/passbook/static/static/robots.txt b/web/robots.txt similarity index 100% rename from passbook/static/static/robots.txt rename to web/robots.txt diff --git a/passbook/static/static/rollup.config.js b/web/rollup.config.js similarity index 100% rename from passbook/static/static/rollup.config.js rename to web/rollup.config.js diff --git a/passbook/static/static/src/api/application.ts b/web/src/api/application.ts similarity index 100% rename from passbook/static/static/src/api/application.ts rename to web/src/api/application.ts diff --git a/passbook/static/static/src/api/client.ts b/web/src/api/client.ts similarity index 100% rename from passbook/static/static/src/api/client.ts rename to web/src/api/client.ts diff --git a/passbook/static/static/src/api/config.ts b/web/src/api/config.ts similarity index 100% rename from passbook/static/static/src/api/config.ts rename to web/src/api/config.ts diff --git a/passbook/static/static/src/api/errors.ts b/web/src/api/errors.ts similarity index 100% rename from passbook/static/static/src/api/errors.ts rename to web/src/api/errors.ts diff --git a/passbook/static/static/src/api/token.ts b/web/src/api/token.ts similarity index 100% rename from passbook/static/static/src/api/token.ts rename to web/src/api/token.ts diff --git a/passbook/static/static/src/api/user.ts b/web/src/api/user.ts similarity index 100% rename from passbook/static/static/src/api/user.ts rename to web/src/api/user.ts diff --git a/passbook/static/static/src/assets/fonts/DINEngschriftStd.woff b/web/src/assets/fonts/DINEngschriftStd.woff similarity index 100% rename from passbook/static/static/src/assets/fonts/DINEngschriftStd.woff rename to web/src/assets/fonts/DINEngschriftStd.woff diff --git a/passbook/static/static/src/assets/fonts/DINEngschriftStd.woff2 b/web/src/assets/fonts/DINEngschriftStd.woff2 similarity index 100% rename from passbook/static/static/src/assets/fonts/DINEngschriftStd.woff2 rename to web/src/assets/fonts/DINEngschriftStd.woff2 diff --git a/passbook/static/static/src/assets/images/flow_background.jpg b/web/src/assets/images/flow_background.jpg similarity index 100% rename from passbook/static/static/src/assets/images/flow_background.jpg rename to web/src/assets/images/flow_background.jpg diff --git a/passbook/static/static/src/assets/images/logo.png b/web/src/assets/images/logo.png similarity index 100% rename from passbook/static/static/src/assets/images/logo.png rename to web/src/assets/images/logo.png diff --git a/passbook/static/static/src/assets/images/logo.svg b/web/src/assets/images/logo.svg similarity index 100% rename from passbook/static/static/src/assets/images/logo.svg rename to web/src/assets/images/logo.svg diff --git a/passbook/static/static/src/assets/images/user-default.png b/web/src/assets/images/user-default.png similarity index 100% rename from passbook/static/static/src/assets/images/user-default.png rename to web/src/assets/images/user-default.png diff --git a/passbook/static/static/src/common/styles.ts b/web/src/common/styles.ts similarity index 100% rename from passbook/static/static/src/common/styles.ts rename to web/src/common/styles.ts diff --git a/passbook/static/static/src/constants.ts b/web/src/constants.ts similarity index 100% rename from passbook/static/static/src/constants.ts rename to web/src/constants.ts diff --git a/passbook/static/static/src/elements/ActionButton.ts b/web/src/elements/ActionButton.ts similarity index 100% rename from passbook/static/static/src/elements/ActionButton.ts rename to web/src/elements/ActionButton.ts diff --git a/passbook/static/static/src/elements/AdminLoginsChart.ts b/web/src/elements/AdminLoginsChart.ts similarity index 100% rename from passbook/static/static/src/elements/AdminLoginsChart.ts rename to web/src/elements/AdminLoginsChart.ts diff --git a/passbook/static/static/src/elements/CodeMirror.ts b/web/src/elements/CodeMirror.ts similarity index 100% rename from passbook/static/static/src/elements/CodeMirror.ts rename to web/src/elements/CodeMirror.ts diff --git a/passbook/static/static/src/elements/Dropdown.ts b/web/src/elements/Dropdown.ts similarity index 100% rename from passbook/static/static/src/elements/Dropdown.ts rename to web/src/elements/Dropdown.ts diff --git a/passbook/static/static/src/elements/FetchFillSlot.ts b/web/src/elements/FetchFillSlot.ts similarity index 100% rename from passbook/static/static/src/elements/FetchFillSlot.ts rename to web/src/elements/FetchFillSlot.ts diff --git a/passbook/static/static/src/elements/Messages.ts b/web/src/elements/Messages.ts similarity index 100% rename from passbook/static/static/src/elements/Messages.ts rename to web/src/elements/Messages.ts diff --git a/passbook/static/static/src/elements/ModalButton.ts b/web/src/elements/ModalButton.ts similarity index 100% rename from passbook/static/static/src/elements/ModalButton.ts rename to web/src/elements/ModalButton.ts diff --git a/passbook/static/static/src/elements/Sidebar.ts b/web/src/elements/Sidebar.ts similarity index 100% rename from passbook/static/static/src/elements/Sidebar.ts rename to web/src/elements/Sidebar.ts diff --git a/passbook/static/static/src/elements/SidebarBrand.ts b/web/src/elements/SidebarBrand.ts similarity index 100% rename from passbook/static/static/src/elements/SidebarBrand.ts rename to web/src/elements/SidebarBrand.ts diff --git a/passbook/static/static/src/elements/SidebarUser.ts b/web/src/elements/SidebarUser.ts similarity index 100% rename from passbook/static/static/src/elements/SidebarUser.ts rename to web/src/elements/SidebarUser.ts diff --git a/passbook/static/static/src/elements/Table.ts b/web/src/elements/Table.ts similarity index 100% rename from passbook/static/static/src/elements/Table.ts rename to web/src/elements/Table.ts diff --git a/passbook/static/static/src/elements/Tabs.ts b/web/src/elements/Tabs.ts similarity index 100% rename from passbook/static/static/src/elements/Tabs.ts rename to web/src/elements/Tabs.ts diff --git a/passbook/static/static/src/elements/TokenCopyButton.ts b/web/src/elements/TokenCopyButton.ts similarity index 100% rename from passbook/static/static/src/elements/TokenCopyButton.ts rename to web/src/elements/TokenCopyButton.ts diff --git a/passbook/static/static/src/index.html b/web/src/index.html similarity index 100% rename from passbook/static/static/src/index.html rename to web/src/index.html diff --git a/passbook/static/static/src/main.ts b/web/src/main.ts similarity index 100% rename from passbook/static/static/src/main.ts rename to web/src/main.ts diff --git a/passbook/static/static/src/pages/FlowShellCard.ts b/web/src/pages/FlowShellCard.ts similarity index 100% rename from passbook/static/static/src/pages/FlowShellCard.ts rename to web/src/pages/FlowShellCard.ts diff --git a/passbook/static/static/src/pages/RouterOutlet.ts b/web/src/pages/RouterOutlet.ts similarity index 100% rename from passbook/static/static/src/pages/RouterOutlet.ts rename to web/src/pages/RouterOutlet.ts diff --git a/passbook/static/static/src/pages/SiteShell.ts b/web/src/pages/SiteShell.ts similarity index 100% rename from passbook/static/static/src/pages/SiteShell.ts rename to web/src/pages/SiteShell.ts diff --git a/passbook/static/static/src/pages/applications/ApplicationViewPage.ts b/web/src/pages/applications/ApplicationViewPage.ts similarity index 100% rename from passbook/static/static/src/pages/applications/ApplicationViewPage.ts rename to web/src/pages/applications/ApplicationViewPage.ts diff --git a/passbook/static/static/src/passbook.css b/web/src/passbook.css similarity index 100% rename from passbook/static/static/src/passbook.css rename to web/src/passbook.css diff --git a/passbook/static/static/src/utils.ts b/web/src/utils.ts similarity index 100% rename from passbook/static/static/src/utils.ts rename to web/src/utils.ts diff --git a/passbook/static/static/tsconfig.json b/web/tsconfig.json similarity index 100% rename from passbook/static/static/tsconfig.json rename to web/tsconfig.json