Commit ecae0e2e authored by 智勇's avatar 智勇

修改git host

parent d804c776
......@@ -29,6 +29,5 @@ RUN echo -e "${BUILD_SCHEMA//@/\n}" >> ./build_info
COPY --from=0 /code/* /home/quant_group/
COPY docker-entrypoint.sh .
RUN chmod +x ./docker-entrypoint.sh
CMD ./docker-entrypoint.sh
\ No newline at end of file
#!/bin/bash
echo 172.30.10.23 git.quantgroup.cn >> /etc/hosts
echo 154.8.170.64 git.quantgroup.cn >> /etc/hosts
curl -sSL http://git.quantgroup.cn/QA/qg-docker-entrypoints/raw/java/tke/ui.sh -o run.sh
sh run.sh
# coding=UTF-8
from __future__ import print_function
import io
import yaml
import fileinput
import os
import os.path
import re
import copy
import sys
import string
f = io.open('replace_config.yaml', 'r', encoding='utf-8')
res = yaml.load(f)
print("全部配置信息:", res)
# 获取当前项目的配置
env = os.environ
project = env.get('SYSTEM_NAME')
config = res.get(project, res.get('common'))
config = sorted(config.items(), key=lambda rule: (rule[1]['order'], rule[0]))
print(project, "的配置信息:", config)
namespace = env.get('NAMESPACE')
print('namespace:', namespace)
print('host:', sys.argv[1])
files = []
acceptType = {'.html', '.js', '.css'}
def findFile (dir):
if os.path.isfile(dir):
suffix = os.path.splitext(dir)[-1]
if (suffix in acceptType):
files.append(dir)
return
else:
for sub in os.listdir(dir):
findFile(dir + '/' + sub)
distPaths = []
if '--' in project:
distPaths.append(os.path.abspath(project.split('--')[0] + '/dist'))
distPaths.append(os.path.abspath(project.split('--')[1] + '/dist'))
else:
distPaths.append(os.path.abspath(project + '/dist'))
# 过滤符合要求的文件路径
for distPath in distPaths:
print("dist路径:", distPath)
findFile(distPath)
# 替换文件中的内容
for file in files:
for line in fileinput.input(file, inplace = 1):
for item in config:
rule = copy.deepcopy(item[1])
if rule.get('useNamespace', None) and rule['to']:
rule['to'] = '-' + namespace + rule['to']
if rule.get('useHost', None):
domain = sys.argv[1].split('.')[0]
rule['to'] = '//' + domain + rule['to']
if rule['reg']:
p = re.compile(r'' + rule['reg'])
line = re.sub(p, rule['to'], line)
print(line, end = '')
fileinput.close()
f.close()
\ No newline at end of file
# reg: 匹配的正则
# to: 正则匹配后替换需要的值
# useNamespace: 是否在替换的值前追加 '-[namespace名称]'
# useHost: 是否在替换时使用该项目域名的第一段
# order 默认0, 负数用在自定义属性上,在通用规则前生效
rule: &rule
reg: ''
to: ''
useNamespace: false
useHost: false
order: 0
lkbDomain: &lkbDomain '.lkbang.net'
# 替换xyqbapi
xyqbApiRule: &xyqbApiRule
<<: *rule
reg: '(?<=\w).xyqb.com'
to: *lkbDomain
useNamespace: true
# 替换quantgroupApi
quantgroupApiRule: &quantgroupApiRule
<<: *rule
reg: '(?<=\w).quantgroup.cn'
to: *lkbDomain
useNamespace: true
# 替换cookie
xyqbCookieRule: &xyqbCookieRule
<<: *rule
reg: '(?<![\w]).xyqb.com'
to: *lkbDomain
qgApiRule: &qgApiRule
<<: *rule
reg: '(?<=\w).q-gp.com'
to: *lkbDomain
useNamespace: true
qgCookieRule: &qgCookieRule
<<: *rule
reg: '(?<![\w]).q-gp.com'
to: *lkbDomain
h5AuthRule: &h5AuthRule
<<: *rule
# reg: 'auth[-a-z]*\.[a-z]*\.[a-z]*'
reg: 'auth.quantgroup.cn'
to: 'operator.liangkebang.com'
staticRule: &staticRule
<<: *rule
reg: '//static[-/0-9a-z.]*public'
to: *lkbDomain
useNamespace: true
useHost: true
# 神测用户采集
bnRule: &bnRule
<<: *rule
reg: 'bn[-/0-9a-z.]*lkbang.net'
to: 'bn.xyqb.com'
order: 8
# 神测测试环境
bnDefaultRule: &bnDefaultRule
<<: *rule
reg: '.com/sa.gif?project=production'
to: '.com/sa.gif?project=default'
common: &common
h5AuthRule: *h5AuthRule
qgApiRule: *qgApiRule
qgCookieRule: *qgCookieRule
quantgroupApiRule: *quantgroupApiRule
staticRule: *staticRule
xyqbApiRule: *xyqbApiRule
xyqbCookieRule: *xyqbCookieRule
bnRule: *bnRule
bnDefaultRule: *bnDefaultRule
\ No newline at end of file
#!/bin/bash
echo "start run ui"
current="/home/quant_group"
echo "current: ${current}"
export NAMESPACE=`cat /var/run/secrets/kubernetes.io/serviceaccount/namespace`
echo "NAMESPACE is $NAMESPACE"
# 运行qa工具
echo "SYSTEM_NAME is $SYSTEM_NAME"
host=`curl -s "http://qaapi.liangkebang.com/proconfig/get_info?system_name=${SYSTEM_NAME}&key=host_name"`
echo "host: ${host}"
for entry in ./*tgz
do
with_ext=$(basename "$entry")
echo ${with_ext}
fname="${with_ext%.*}"
echo "mkdir -p ${current}/$fname"
mkdir -p ${current}/$fname
echo "tar zxf ${current}/$with_ext -C ${current}/$fname"
tar zxf ${current}/$with_ext -C ${current}/$fname
done
# curl -sSL http://git.quantgroup.cn/QA/config_repository/raw/master/yaml/replace.py -o replace.py
# curl -sSL http://git.quantgroup.cn/QA/config_repository/raw/master/yaml/replace_config.yaml -o replace_config.yaml
python replace.py $host;
echo "/usr/bin/openresty -g 'daemon off;'"
/usr/bin/openresty -g 'daemon off;'
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment