Commit 0feedc49 authored by xuezj's avatar xuezj

初始化

parent a7b9f566
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
### 指南
#### 腾讯云仓库
```
// 登录
docker login --username=xxx ccr.ccs.tencentyun.com
// 拉取镜像
sudo docker pull ccr.ccs.tencentyun.com/qa-db/redis:[tag]
// 推送镜像
docker tag [ImageId] ccr.ccs.tencentyun.com/qa-db/redis:[tag]
docker push ccr.ccs.tencentyun.com/qa-db/redis:[tag]
```
#### 自建仓库 - 192.1.68.4.4
```
// 登录
docker login --username=xxx 192.168.4.4
// 拉取镜像
sudo docker pull 192.168.4.4/xxx
// 推送镜像
docker tag [ImageId] 192.168.4.4/xxx
docker push 192.168.4.4/xxx
```
### 镜像说明
1. redis
```
基于redis-alpine,减小镜像大小
业务需要支持多端口,所以镜像中启动了5个单独的实例。
```
2. ui
```
基于centos7的openresty官方镜像
配置文件路径 /etc/nginx/conf.d/*.conf, 默认叫default.conf
ui项目,SYSTEM_NAME从环境变量获取,所以需要在nginx.conf中增加env
abTest的项目,在构建镜像时使用参数CONFIG=abTest/paycenter.conf
```
FROM redis:3-alpine
WORKDIR /home/quantgroups/redis
COPY conf/*.conf ./conf/
COPY start.sh .
RUN mkdir /var/log/redis \
&& mkdir /var/lib/redis \
&& mkdir /var/run/redis
EXPOSE 6379 6380 6381 6382 6383
CMD ./start.sh
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
daemonize no
pidfile /var/run/redis/redis.pid
port 6383
bind 0.0.0.0
timeout 0
tcp-keepalive 0
loglevel notice
logfile /var/log/redis.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis/
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
#bin/bash
redis-server /home/quantgroups/redis/conf/redis-6380.conf &
redis-server /home/quantgroups/redis/conf/redis-6381.conf &
redis-server /home/quantgroups/redis/conf/redis-6382.conf &
redis-server /home/quantgroups/redis/conf/redis-6383.conf &
redis-server /home/quantgroups/redis/conf/redis-6379.conf
\ No newline at end of file
# 基于centos7
FROM openresty/openresty:1.13.6.2-centos
RUN yum -y install epel-release \
&& yum -y install python-pip
WORKDIR /home/quant_group
# 加入测试工具集
COPY qa-replace .
RUN pip install -r requirements.txt \
&& yum clean all
# 拷贝nginx配置
COPY lua/*.lua /etc/nginx/lua/
ARG CONFIG=default.conf
COPY conf/nginx.conf /usr/local/openresty/nginx/conf/
COPY conf/${CONFIG} /etc/nginx/conf.d/
# 拷贝代码, code/xjd-ui/dist
# 先打包好代码镜像,然后从镜像中拷贝??
COPY code .
COPY docker-entrypoint.sh ./
CMD ./docker-entrypoint.sh
#!/bin/bash
tag=2.3
docker build -t test-ui . && docker tag test-ui 192.168.4.4/tmp/test-ui:${tag} && docker push 192.168.4.4/tmp/test-ui:${tag}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>22</title>
</head>
<body>
<h1>op-xuezhijie.liangkebang.com</h1>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>1111</title>
</head>
<body>
<h1>1</h1>
</body>
</html>
\ No newline at end of file
server {
listen 80;
server_name _;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 4;
gzip_types text/plain application/x-javascript text/css application/xml application/javascript;
gzip_vary on;
set $normalPath "/home/quant_group/spider-center-ui/dist";
set $channelPath "/home/quant_group/new-spider-center-ui/dist";
set $registerChannel "999999";
set $merchantChannel "";
set $excludeChannel "504,900";
set $tailNumber "1,2,3,4,5,6,7,8,9";
location / {
expires -1;
set_by_lua_file $rootPath /etc/nginx/lua/phoneChannel.lua;
header_filter_by_lua_file /etc/nginx/lua/addCookie.lua;
root $rootPath;
try_files $uri $uri/ /index.html?$query_string;
}
}
server {
listen 80;
server_name _;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 4;
gzip_types text/plain application/x-javascript text/css application/xml application/javascript;
gzip_vary on;
location / {
expires -1;
set_by_lua $rootPath '
local pre = "/home/quant_group/code/";
local sys = os.getenv("SYSTEM_NAME");
return pre..sys.."/dist"
';
root $rootPath;
try_files $uri $uri/ /index.html?$query_string;
}
}
\ No newline at end of file
#user nobody;
worker_processes 1;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
#pid logs/nginx.pid;
env SYSTEM_NAME;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
\ No newline at end of file
#!/bin/bash
echo 192.168.4.3 git.q-gp.com >> /etc/hosts
curl -sSL http://git.q-gp.com/QA/qg-docker-entrypoints/raw/tke-ui/tke/ui.sh -o run.sh
sh run.sh
local args = ngx.req.get_uri_args()
local register_uri = args['registerFrom']
local merchant_uri = args['merchantId']
if (register_uri) then
ngx.header['Set-Cookie'] = {'registerFrom=' .. register_uri .. '; path=/; domain=.liangkebang.com;'}
end
if (merchant_uri) then
ngx.header['Set-Cookie'] = {'merchantId=' .. merchant_uri .. '; path=/; domain=.liangkebang.com;'}
end
\ No newline at end of file
function string.split(str)
local splitlist = {};
string.gsub(str, '[^,]+', function(w) table.insert(splitlist, w) end )
return splitlist;
end
function isInTable(value, tbl)
for k,v in ipairs(tbl) do
if v == value then
return true;
end
end
return false;
end
local path = ngx.var.normalPath;
local channelPath = ngx.var.channelPath;
-- 解析手机号和特殊渠道
local tailNumbers = string.split(ngx.var.tailNumber);
local excludeChannel = string.split(ngx.var.excludeChannel)
-- 解析渠道设置
local register = string.split(ngx.var.registerChannel);
-- cookie值
local register_cookie = ngx.var.cookie_registerFrom
-- uri参数值
local args = ngx.req.get_uri_args()
local register_uri = args['registerFrom']
local phoneNo = args['phoneNo']
if (not phoneNo or string.len(phoneNo) == 0) then
phoneNo = ngx.var.cookie_phoneNo
end
local baiTiao = '222';
if (register_uri) then
isBaitiao = register_uri == baiTiao
else
isBatitiao = register_cookie == baiTiao
end
if (isBatitiao) then
return channelPath;
end
-- 没有设置渠道,设置了手机号,属于特殊渠道(不属于特殊,但符合尾号规则)时,返回旧版
if (ngx.var.excludeChannel ~= '' or ngx.var.tailNumber ~= '') then
local hitExclude = isInTable(register_uri, excludeChannel) or isInTable(register_cookie, excludeChannel)
if (hitExclude) then
return path;
end
-- 是否符合手机尾号规则
local hitTailNumber = false
if phoneNo then
for key,value in ipairs(tailNumbers)
do
if (string.match(phoneNo, value..'$')) then
hitTailNumber = true
break
end
end
end
if (hitTailNumber) then
return channelPath;
end
end
return channelPath;
function string.split(str)
local splitlist = {};
string.gsub(str, '[^,]+', function(w) table.insert(splitlist, w) end )
return splitlist;
end
function isInTable(value, tbl)
for k,v in ipairs(tbl) do
if v == value then
return true;
end
end
return false;
end
local path = ngx.var.normalPath;
local channelPath = ngx.var.channelPath;
-- 没有设置渠道,返回旧目录
if (ngx.var.registerChannel == '' and ngx.var.merchantChannel == '') then
return path;
end
-- 解析渠道设置
local register = string.split(ngx.var.registerChannel);
local merchant = string.split(ngx.var.merchantChannel);
-- cookie值
local register_cookie = ngx.var.cookie_registerFrom
local merchant_cookie = ngx.var.cookie_merchantId
-- uri参数值
local args = ngx.req.get_uri_args()
local register_uri = args['registerFrom']
local merchant_uri = args['merchantId']
-- 优先匹配参数中的registerFrom
if (register_uri) then
hitRegister = isInTable(register_uri, register)
else
hitRegister = isInTable(register_cookie, register)
end
-- 优先匹配参数中的merchantId
if (merchant_uri) then
hitMerchantId = isInTable(merchant_uri, register)
else
hitMerchantId = isInTable(merchant_cookie, register)
end
local baiTiao = '222';
--
if (register_uri) then
isBaitiao = register_uri == baiTiao
else
isBatitiao = register_cookie == baiTiao
end
-- 是白条,未设置merchantId规则,命中
if (isBaitiao and ngx.var.merchantChannel == '') then
return channelPath
end
-- 是白条,设置了merchantId规则,匹配merchantId后命中
if (isBaitiao and ngx.var.merchantChannel ~= '' and hitMerchantId) then
return channelPath
end
-- 不是白条,匹配registerFrom后命中
if ( not isBaitiao and hitRegister) then
return channelPath
end
return path;
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: test-ui
namespace: xuezhijie
spec:
replicas: 1
strategy:
type: Recreate
revisionHistoryLimit: 0
template:
metadata:
labels:
app: test-ui
spec:
restartPolicy: Always
containers:
- name: test-ui-v1
imagePullPolicy: Always
env:
- name: SYSTEM_NAME
value: xjd-ui
- name: NAMESPACE
value: xuezhijie
image: 192.168.4.4/tmp/test-ui:2.2
ports:
- containerPort: 80
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
name: test-ui
namespace: xuezhijie
spec:
ports:
- name: tcp-80-80-fwdy6
port: 80
protocol: TCP
targetPort: 80
sessionAffinity: None
type: ClusterIP
\ 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