Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
docker-test
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Kunkka王辉
docker-test
Commits
e2e26007
Commit
e2e26007
authored
Sep 21, 2023
by
Kunkka王辉
😲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
安装脚本优化
parent
a6e840f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
50 deletions
+28
-50
install.sh
install.sh
+28
-50
No files found.
install.sh
View file @
e2e26007
#!/bin/bash
# 获取本机ip 192 ip
HOST_IP
=
$(
hostname
-I
|
grep
-E
"192
\.
168
\.
[0-9]+
\.
[0-9]+"
-o
)
OS_IS_LINUX
=
'yes'
;
if
[
$(
uname
-o
)
!=
"GNU/Linux"
]
;
then
OS_IS_LINUX
=
'no'
;
fi
DOCKER_YES
=
'yes'
;
if
[
!
`
command
-v
docker
`
]
;
then
DOCKER_YES
=
'no'
;
fi
;
GIT_YES
=
'yes'
;
if
[
!
`
command
-v
git
`
]
;
then
DOCKER_YES
=
'no'
;
fi
;
TAR_YES
=
'yes'
;
if
[
!
`
command
-v
tar
`
]
;
then
DOCKER_YES
=
'no'
;
fi
;
OS_IS_LINUX
=
'yes'
if
[
$(
uname
-o
)
!=
"GNU/Linux"
]
;
then
OS_IS_LINUX
=
'no'
;
fi
DOCKER_YES
=
'yes'
if
[
!
$(
command
-v
docker
)
]
;
then
DOCKER_YES
=
'no'
;
fi
GIT_YES
=
'yes'
if
[
!
$(
command
-v
git
)
]
;
then
DOCKER_YES
=
'no'
;
fi
TAR_YES
=
'yes'
if
[
!
$(
command
-v
tar
)
]
;
then
DOCKER_YES
=
'no'
;
fi
AVAILABLE_MEMORY
=
$(
free
-m
|
awk
'NR==2{print $7}'
)
CAN_COMPILE
=
0
MEM_MSG
=
',小于4G,不足跑前端编译'
if
[
$AVAILABLE_MEMORY
-gt
4200
]
;
then
CAN_COMPILE
=
1
MEM_MSG
=
'yes'
fi
COMPOSE_CMD
=
'docker-compose'
if
docker
--help
|
grep
compose
>
/dev/null
;
then
COMPOSE_CMD
=
'docker compose'
if
docker
--help
|
grep
compose
>
/dev/null
;
then
COMPOSE_CMD
=
'docker compose'
fi
DOCKER_COMPOSE_YES
=
'yes'
;
if
[
!
`
command
-v
docker-compose
`
]
&&
[
"
$COMPOSE_CMD
"
!=
'docker compose'
]
;
then
DOCKER_COMPOSE_YES
=
'no'
;
fi
;
PORT_YES
=
'yes'
;
if
ss
-tpl
|
grep
-E
'8118|8181'
>
/dev/null
;
then
PORT_YES
=
'no'
;
fi
;
cat
<<
EOF
DOCKER_COMPOSE_YES
=
'yes'
if
[
!
$(
command
-v
docker-compose
)
]
&&
[
"
$COMPOSE_CMD
"
!=
'docker compose'
]
;
then
DOCKER_COMPOSE_YES
=
'no'
;
fi
PORT_YES
=
'yes'
if
ss
-tpl
|
grep
-E
'8118|8181'
>
/dev/null
;
then
PORT_YES
=
'no'
;
fi
cat
<<
EOF
检查环境:
1. 是否是linux系统
$OS_IS_LINUX
2. docker
$DOCKER_YES
...
...
@@ -26,17 +26,16 @@ cat <<EOF
4. docker-compose/docker compose
$DOCKER_COMPOSE_YES
5. tar
$TAR_YES
6. 端口8118,8181是否可用
$PORT_YES
7. 本机可用内存
${
AVAILABLE_MEMORY
}
M
$MEM_MSG
8. 本机IP
$HOST_IP
EOF
if
echo
"
$TAR_YES$GIT_YES$DOCKER_COMPOSE_YES$OS_IS_LINUX$DOCKER_YES$PORT_YES
"
|
grep
no
>
/dev/null
;
then
exit
;
if
echo
"
$TAR_YES$GIT_YES$DOCKER_COMPOSE_YES$OS_IS_LINUX$DOCKER_YES$PORT_YES
"
|
grep
no
>
/dev/null
;
then
exit
fi
# 变量声明
ENV
=
'dev'
CODE_DIR
=
$(
pwd
)
/code-
$ENV
for
arg
in
"
$@
"
;
do
if
[
-n
"
$arg
"
]
;
then
for
arg
in
"
$@
"
;
do
if
[
-n
"
$arg
"
]
;
then
ENV
=
"
$arg
"
break
fi
...
...
@@ -44,44 +43,24 @@ done
BUILD_DIR
=
galaxy-
$ENV
if
[
!
-d
$CODE_DIR
]
;
then
mkdir
-p
$CODE_DIR
mkdir
-p
$CODE_DIR
fi
echo
'拉取工具镜像'
docker pull gplane/pnpm:7.4
docker pull node:14.20-alpine
cd
$CODE_DIR
echo
"下载demo代码"
curl
-o
data.tgz -#
http://192.168.11.163/demo/code-demo-920.tgz
curl
-o
data.tgz -# http://192.168.11.163/demo/code-demo-920.tgz
echo
'解压缩(每1000个文件输出一个.)'
tar
--checkpoint
=
.1000
--checkpoint-action
=
dot
--strip-components
=
1
-xf
data.tgz
tar
--checkpoint
=
.1000
--checkpoint-action
=
dot
--strip-components
=
1
-xf
data.tgz
rm
-f
data.tgz
echo
'storage 目录权限处理'
find ./
-type
d
-name
'storage'
-exec
chmod
-R
0777
{}
+
cd
../
# 到上一层
echo
'下载前端编译项目'
curl
-o
front.tgz -# http://192.168.11.163/demo/code-front-compile.tgz
echo
'解压缩中.'
tar
--checkpoint
=
.1000
--checkpoint-action
=
dot
-xf
front.tgz
rm
-f
front.tgz
cd
compile/Document-System
sed
-i
"s/192.168.11.163/
$HOST_IP
/g"
.env.dev
cat
.env.dev
if
[
$CAN_COMPILE
-eq
1
]
;
then
echo
'开始编译打包前端dwp/main'
docker run
--rm
-v
$(
pwd
)
:/app
-w
/app gplane/pnpm:7.4 vite build
--mode
dev
--outDir
main
yes
|
cp
-rf
main
$CODE_DIR
/dwp/
cd
../compile/crm
sed
-i
"s/192.168.11.163/
$HOST_IP
/g"
.env.testa
cat
.env.testa
echo
'开始编译打包前端crm'
cd
$CODE_DIR
/../compile/crm
docker run
--rm
-v
$(
pwd
)
:/app
-w
/app node:14.20-alpine node_modules/@vue/cli-service/bin/vue-cli-service build
--mode
testa
--dest
crm
yes
|
cp
-rf
crm
$CODE_DIR
/
fi
find ./
-type
d
-name
'storage'
-exec
chmod
-R
0777
{}
+
cd
$CODE_DIR
/crm
grep
-rlZ
192.168.11.163 ./ | xargs
-0
sed
-i
"s/192.168.11.163/
$HOST_IP
/g"
cd
$CODE_DIR
/dwp/main
grep
-rlZ
192.168.11.163 ./ | xargs
-0
sed
-i
"s/192.168.11.163/
$HOST_IP
/g"
cd
$CODE_DIR
/../
git clone http://gitlab.galaxy-immi.com/kunkka.wh/docker-test.git
$BUILD_DIR
cd
$BUILD_DIR
cat
<<
EOF
>
.env
cat
<<
EOF
>.env
# 环境变量env dev,test,test1,test2等区分
ENV=
$ENV
# 服务宿主机的端口
...
...
@@ -104,4 +83,3 @@ http://$HOST_IP:8118/ DWP
http://
$HOST_IP
:8181/ CRM
安装完成!
EOF
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