Skip to content

Commit

Permalink
Merge branch 'TencentBlueKing:ft_tenant' into ft_tenant
Browse files Browse the repository at this point in the history
  • Loading branch information
Canway-shiisa authored Aug 16, 2023
2 parents 053cbbc + df94a53 commit 63fd5ec
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 27 deletions.
19 changes: 15 additions & 4 deletions src/bk-user/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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"]
3 changes: 2 additions & 1 deletion src/bk-user/bkuser/common/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/bk-user/bkuser/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/pages/bk.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
cache: true,
open: true,
replaceStatic: true,
outputAssetsDirName: '',

// webpack config 配置
configureWebpack() {
Expand Down
20 changes: 4 additions & 16 deletions src/pages/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="{{ STATIC_URL }}/images/favicon.png" type="image/x-icon" />
<link rel="shortcut icon" href="{{ STATIC_URL }}/images/favicon.png" type="image/x-icon" />
<link rel="icon" href="{{ BK_STATIC_URL }}/images/favicon.png" type="image/x-icon" />
<link rel="shortcut icon" href="{{ BK_STATIC_URL }}/images/favicon.png" type="image/x-icon" />
<meta charset="utf-8">
<title> index </title>
</head>
Expand All @@ -12,22 +12,10 @@
// 登录页面
window.BK_LOGIN_URL = '{{ BK_LOGIN_URL }}'
// 开发环境域名
window.AJAX_BASE_URL = '{{ AJAX_URL_PREFIX }}'
window.AJAX_BASE_URL = '{{ AJAX_BASE_URL }}'
// 静态资源路径
window.STATIC_URL = '{{ STATIC_URL }}'
window.BK_STATIC_URL = '{{ BK_STATIC_URL }}'
window.CSRF_COOKIE_NAME = '{{ CSRF_COOKIE_NAME }}'
// var SITE_URL = '<%= process.env.BK_SITE_URL %>'
// var BK_STATIC_URL = '<%= process.env.BK_STATIC_URL %>'
// // 当前应用的环境,预发布环境为 stag,正式环境为 prod
// var BKPAAS_ENVIRONMENT = '<%= process.env.BK_PAAS_ENVIRONMENT %>'
// // EngineApp名称,拼接规则:bkapp-{appcode}-{BKPAAS_ENVIRONMENT}
// var BKPAAS_ENGINE_APP_NAME = '<%= process.env.BK_PAAS_ENGINE_APP_NAME %>'
// // 内部版对应ieod,外部版对应tencent,混合云版对应clouds
// var BKPAAS_ENGINE_REGION = '<%= process.env.BK_PAAS_ENGINE_REGION %>'
// // APP ID
// var BKPAAS_APP_ID = '<%= process.env.BK_PAAS_APP_ID %>'
// var BKPAAS_APP_SECRET = '<%= process.env.BK_PAAS_APP_SECRET %>'
// var BK_LOGIN_URL = '<%= process.env.BK_LOGIN_URL %>'
</script>
</body>
</html>
2 changes: 0 additions & 2 deletions src/pages/paas-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,3 @@ app.set('view engine', 'html');
app.listen(PORT, () => {
console.log(`App is running in port ${PORT}`);
});


6 changes: 3 additions & 3 deletions src/pages/src/http/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ interface Http {

const baseURL = /http(s)?:\/\//.test(window.AJAX_BASE_URL)
? window.AJAX_BASE_URL
: location.origin + window.STATIC_URL + window.AJAX_BASE_URL;
: location.origin + window.AJAX_BASE_URL;

const axiosInstance = axios.create({
baseURL,
withCredentials: true,
xsrfCookieName: window.CSRF_COOKIE_NAME,
xsrfHeaderName: 'X-CSRFToken',
headers: {
'X-CSRFToken': window.CSRF_COOKIE_NAME,
'X-CSRFToken': Cookies.get(window.CSRF_COOKIE_NAME),
'x-requested-with': 'XMLHttpRequest',
},
});
Expand Down Expand Up @@ -120,5 +120,5 @@ methods.forEach((method) => {
},
});
});

export default http as Http;

0 comments on commit 63fd5ec

Please sign in to comment.