diff --git a/src/bk-user/Dockerfile b/src/bk-user/Dockerfile index 8988403bd..28bb9c0bb 100644 --- a/src/bk-user/Dockerfile +++ b/src/bk-user/Dockerfile @@ -1,10 +1,18 @@ -FROM python:3.10.12-slim-buster +FROM node:18.17.1-bullseye-slim AS StaticBuilding +ENV NPM_VERSION 9.6.7 + +COPY src/pages / +WORKDIR / +RUN npm install +RUN npm run build + +FROM python:3.10.12-slim-bullseye USER root RUN rm /etc/apt/sources.list && \ - echo "deb https://mirrors.tencent.com/debian buster main" >> /etc/apt/sources.list && \ - echo "deb https://mirrors.tencent.com/debian-security buster/updates main" >> /etc/apt/sources.list && \ - echo "deb https://mirrors.tencent.com/debian buster-updates main" >> /etc/apt/sources.list + echo "deb https://mirrors.tencent.com/debian bullseye main" >> /etc/apt/sources.list && \ + echo "deb https://mirrors.tencent.com/debian-security bullseye-security main" >> /etc/apt/sources.list && \ + echo "deb https://mirrors.tencent.com/debian bullseye-updates main" >> /etc/apt/sources.list RUN mkdir ~/.pip && printf '[global]\nindex-url = https://mirrors.tencent.com/pypi/simple/' > ~/.pip/pip.conf @@ -25,4 +33,7 @@ COPY src/bk-user/bkuser /app/bkuser COPY src/bk-user/bin /app/bin COPY src/bk-user/manage.py /app +COPY --from=StaticBuilding /dist /app/staticfiles +COPY --from=StaticBuilding /dist/index.html /app/templates/index.html + CMD ["bash", "/app/bin/start.sh"] diff --git a/src/bk-user/bkuser/common/views.py b/src/bk-user/bkuser/common/views.py index 5395678a2..fb16b1ff2 100644 --- a/src/bk-user/bkuser/common/views.py +++ b/src/bk-user/bkuser/common/views.py @@ -157,10 +157,11 @@ def get(self, request, *args, **kwargs): context = { # BK_DOMAIN "BK_DOMAIN": settings.BK_DOMAIN, + "BK_LOGIN_URL": settings.BK_LOGIN_URL.rstrip("/"), "BK_USER_URL": settings.BK_USER_URL.rstrip("/"), "AJAX_BASE_URL": settings.AJAX_BASE_URL.rstrip("/"), # 去除末尾的 /, 前端约定 - "STATIC_URL": settings.STATIC_URL.rstrip("/"), + "BK_STATIC_URL": settings.STATIC_URL.rstrip("/"), # 去除开头的 . document.domain需要 "SESSION_COOKIE_DOMAIN": settings.SESSION_COOKIE_DOMAIN.lstrip("."), # csrftoken name diff --git a/src/bk-user/bkuser/settings.py b/src/bk-user/bkuser/settings.py index 8d8a45e26..6d0701335 100644 --- a/src/bk-user/bkuser/settings.py +++ b/src/bk-user/bkuser/settings.py @@ -156,7 +156,7 @@ BK_DOMAIN = env.str("BK_DOMAIN", default="") # BK USER URL BK_USER_URL = env.str("BK_USER_URL") -AJAX_BASE_URL = SITE_URL + "api/v1" +AJAX_BASE_URL = "" # csrf _BK_USER_URL_PARSE_URL = urlparse(BK_USER_URL) diff --git a/src/pages/bk.config.js b/src/pages/bk.config.js index 8d700efba..0847129cd 100644 --- a/src/pages/bk.config.js +++ b/src/pages/bk.config.js @@ -8,6 +8,7 @@ module.exports = { cache: true, open: true, replaceStatic: true, + outputAssetsDirName: '', // webpack config 配置 configureWebpack() { diff --git a/src/pages/index.html b/src/pages/index.html index 73b2975f6..8679fc84a 100644 --- a/src/pages/index.html +++ b/src/pages/index.html @@ -1,8 +1,8 @@
- - + +