root: move webapp to /web (#347)

* root: move webapp to /web

* root: fix static build

* root: fix static files not being served for e2e tests
This commit is contained in:
Jens L 2020-11-28 19:43:42 +01:00 committed by GitHub
parent 127ffbd456
commit 9466f91466
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 15 additions and 26 deletions

View File

@ -1,6 +1,6 @@
env env
helm helm
passbook-ui
static static
htmlcov
*.env.yml *.env.yml
**/node_modules node_modules/**

View File

@ -9,7 +9,7 @@ updates:
assignees: assignees:
- BeryJu - BeryJu
- package-ecosystem: npm - package-ecosystem: npm
directory: "/passbook/static/static" directory: "/web"
schedule: schedule:
interval: daily interval: daily
time: "04:00" time: "04:00"

View File

@ -31,3 +31,8 @@ local-stack:
docker build -t beryju/passbook:testng . docker build -t beryju/passbook:testng .
docker-compose up -d docker-compose up -d
docker-compose run --rm server migrate 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

View File

@ -272,7 +272,7 @@ stages:
displayName: Build static files for e2e displayName: Build static files for e2e
inputs: inputs:
script: | script: |
cd passbook/static/static cd web
npm i npm i
npm run build npm run build
- task: CmdLine@2 - task: CmdLine@2

View File

@ -48,12 +48,9 @@ LOGGER = structlog.get_logger()
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # 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__)))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
STATIC_ROOT = BASE_DIR + "/static" STATIC_ROOT = BASE_DIR + "/static"
STATICFILES_DIRS = [BASE_DIR + "/web"]
MEDIA_ROOT = BASE_DIR + "/media" 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 = CONFIG.y(
"secret_key", "9$@r!d^1^jrn#fk#1#@ks#9&i$^s#1)_13%$rwjrhd=e8jfi_s" "secret_key", "9$@r!d^1^jrn#fk#1#@ks#9&i$^s#1)_13%$rwjrhd=e8jfi_s"
) # noqa Debug ) # noqa Debug
@ -124,7 +121,6 @@ INSTALLED_APPS = [
"passbook.stages.otp_time.apps.PassbookStageOTPTimeConfig", "passbook.stages.otp_time.apps.PassbookStageOTPTimeConfig",
"passbook.stages.otp_validate.apps.PassbookStageOTPValidateConfig", "passbook.stages.otp_validate.apps.PassbookStageOTPValidateConfig",
"passbook.stages.password.apps.PassbookStagePasswordConfig", "passbook.stages.password.apps.PassbookStagePasswordConfig",
"passbook.static.apps.PassbookStaticConfig",
"rest_framework", "rest_framework",
"django_filters", "django_filters",
"drf_yasg2", "drf_yasg2",

View File

@ -65,6 +65,7 @@ if settings.DEBUG:
[ [
path("-/debug/", include(debug_toolbar.urls)), path("-/debug/", include(debug_toolbar.urls)),
] ]
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+ urlpatterns + urlpatterns
) )

View File

@ -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"

View File

@ -34,21 +34,18 @@ ENV PASSBOOK_REDIS__HOST=redis
ENV PASSBOOK_POSTGRESQL__USER=passbook ENV PASSBOOK_POSTGRESQL__USER=passbook
# CI Password, same as in .github/workflows/ci.yml # CI Password, same as in .github/workflows/ci.yml
ENV PASSBOOK_POSTGRESQL__PASSWORD="EK-5jnKfjrGRm<77" 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 FROM node as npm-builder
COPY --from=static-build /app/static/src /static/src COPY ./web /static/
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
RUN cd /static && npm i && npm run build RUN cd /static && npm i && npm run build
FROM nginx FROM nginx
COPY --from=static-build /app/static /usr/share/nginx/html/static 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/node_modules /usr/share/nginx/html/static/node_modules
COPY --from=npm-builder /static/dist/* /usr/share/nginx/html/static/dist/ COPY --from=npm-builder /static/dist/* /usr/share/nginx/html/static/dist/

View File

Before

Width:  |  Height:  |  Size: 670 KiB

After

Width:  |  Height:  |  Size: 670 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 68 B

After

Width:  |  Height:  |  Size: 68 B

View File

Before

Width:  |  Height:  |  Size: 284 B

After

Width:  |  Height:  |  Size: 284 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 351 B

After

Width:  |  Height:  |  Size: 351 B

View File

Before

Width:  |  Height:  |  Size: 402 B

After

Width:  |  Height:  |  Size: 402 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 543 B

After

Width:  |  Height:  |  Size: 543 B

View File

Before

Width:  |  Height:  |  Size: 368 B

After

Width:  |  Height:  |  Size: 368 B

View File

Before

Width:  |  Height:  |  Size: 878 B

After

Width:  |  Height:  |  Size: 878 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 670 KiB

After

Width:  |  Height:  |  Size: 670 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 68 B

After

Width:  |  Height:  |  Size: 68 B