Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qg-dockerfiles
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
qg-dockerfiles
Commits
e30d723b
Commit
e30d723b
authored
Nov 15, 2018
by
xuezj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
替换测试
parent
2d7d3a12
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
0 deletions
+96
-0
Dockerfile
templates/lua-ui/Dockerfile
+3
-0
replace.py
templates/lua-ui/replace.py
+59
-0
replace_config.yaml
templates/lua-ui/replace_config.yaml
+34
-0
No files found.
templates/lua-ui/Dockerfile
View file @
e30d723b
...
@@ -21,5 +21,8 @@ COPY *.lua /usr/local/openresty/nginx/lua/
...
@@ -21,5 +21,8 @@ COPY *.lua /usr/local/openresty/nginx/lua/
COPY
docker-entrypoint.sh .
COPY
docker-entrypoint.sh .
COPY
*tgz ./
COPY
*tgz ./
COPY
replace_config.yaml .
COPY
replace.py .
RUN
chmod
+x ./docker-entrypoint.sh
RUN
chmod
+x ./docker-entrypoint.sh
CMD
./docker-entrypoint.sh
CMD
./docker-entrypoint.sh
\ No newline at end of file
templates/lua-ui/replace.py
0 → 100644
View file @
e30d723b
import
yaml
import
fileinput
import
os
import
os.path
import
re
import
copy
f
=
open
(
'replace_config.yaml'
,
encoding
=
'utf-8'
)
res
=
yaml
.
load
(
f
)
print
(
"全部配置信息:"
,
res
)
# 查看配置中是否有当前项目
env
=
os
.
environ
project
=
env
.
get
(
'SYSTEM_NAME'
)
distPath
=
os
.
path
.
abspath
(
project
+
'/dist'
)
config
=
res
.
get
(
project
,
res
.
get
(
'common'
))
print
(
project
,
"的配置信息:"
,
config
)
print
(
"dist路径:"
,
distPath
)
# 根据内容进行替换
namespace
=
env
.
get
(
'NAMESPACE'
)
print
(
'namespace:'
,
namespace
)
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
)
# 过滤符合要求的文件路径
findFile
(
distPath
)
# print(files)
# 替换文件中的内容
for
file
in
files
:
# print(file)
for
line
in
fileinput
.
input
(
file
,
inplace
=
1
):
for
item
in
config
:
if
not
config
[
item
]:
continue
rule
=
copy
.
deepcopy
(
config
[
item
])
if
rule
.
get
(
'useNamespace'
,
None
)
and
rule
[
'to'
]:
rule
[
'to'
]
=
'-'
+
namespace
+
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
templates/lua-ui/replace_config.yaml
0 → 100644
View file @
e30d723b
# reg: 匹配的正则
# to: 正则匹配后替换需要的值
# useNamespace: 是否在替换的值前追加 '-[namespace名称]'
lkbDomain
:
&lkbDomain
'
.liangkebang.com'
# 替换xyqbapi
xyqbApiRule
:
&xyqbApiRule
reg
:
'
(?<=\w).xyqb.com'
to
:
*lkbDomain
useNamespace
:
true
# 替换cookie,需要放在api规则后;或者需要改正则
xyqbCookieRule
:
&xyqbCookieRule
reg
:
'
.xyqb.com'
to
:
*lkbDomain
qgApiRule
:
&qgApiRule
reg
:
'
(?<=\w).q-gp.com'
to
:
*lkbDomain
useNamespace
:
true
# todo: 看哪个项目需要
h5AuthRule
:
@
h5AuthRule
reg
:
'
h5.auth.quantgroup.cn'
to
:
'
operator.liangkebang.com'
# todo: quantgroup.cn
common
:
&common
xyqbApiRule
:
*xyqbApiRule
qgApiRule
:
*qgApiRule
xyqbCookieRule
:
*xyqbCookieRule
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment