Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加maven插件在build生命周期支持ui dist与docker image构建 #46

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
target/
!.mvn/wrapper/maven-wrapper.jar

.node
######################################################################
# IDE

Expand Down
14 changes: 14 additions & 0 deletions docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
git.properties

mysql/data/*
mysql/logs/*.log
mysql/db/*.sql

nacos/logs/*.log

nginx/html/*
nginx/logs/*.log

redis/data/*

ruoyi/**/jar/*.jar
98 changes: 98 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash

[[ -z "$source_directory" ]] && source_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
[[ "$source_directory" == "/dev/fd" ]] && source_directory="$PWD"

# 使用说明,用来提示输入参数
usage() {
echo "Usage: sh 执行脚本.sh [all|base|modules|ui|service]"
exit 1
}

all() {
base
modules
}

# 启动基础环境(必须)
base(){
# copy sql
echo "begin copy sql "
cp ../sql/ry_20230706.sql ./mysql/db
cp ../sql/ry_config_20220929.sql ./mysql/db
docker-compose build ruoyi-mysql ruoyi-redis ruoyi-nacos
}

# 启动程序模块(必须)
modules(){
ui
service
}

# 启动程序模块(必须)
ui(){
cd $source_directory/../ruoyi-ui
echo "build ui: $PWD"
npm --version
npm install && npm run build:prod

cd $source_directory/
# copy html
echo "begin copy html "
cp -r ../ruoyi-ui/dist/** ./nginx/html/dist
docker-compose build ruoyi-nginx
}

# 启动程序模块(必须)
service(){
cd $source_directory/../
echo "build service: $PWD"
mvn --version
mvn clean package -Dmaven.test.skip=true

cd $source_directory/
# copy jar
echo "begin copy ruoyi-gateway "
cp ../ruoyi-gateway/target/ruoyi-gateway.jar ./ruoyi/gateway/jar

echo "begin copy ruoyi-auth "
cp ../ruoyi-auth/target/ruoyi-auth.jar ./ruoyi/auth/jar

echo "begin copy ruoyi-visual "
cp ../ruoyi-visual/ruoyi-monitor/target/ruoyi-visual-monitor.jar ./ruoyi/visual/monitor/jar

echo "begin copy ruoyi-modules-system "
cp ../ruoyi-modules/ruoyi-system/target/ruoyi-modules-system.jar ./ruoyi/modules/system/jar

echo "begin copy ruoyi-modules-file "
cp ../ruoyi-modules/ruoyi-file/target/ruoyi-modules-file.jar ./ruoyi/modules/file/jar

echo "begin copy ruoyi-modules-job "
cp ../ruoyi-modules/ruoyi-job/target/ruoyi-modules-job.jar ./ruoyi/modules/job/jar

echo "begin copy ruoyi-modules-gen "
cp ../ruoyi-modules/ruoyi-gen/target/ruoyi-modules-gen.jar ./ruoyi/modules/gen/jar
docker-compose build ruoyi-nginx ruoyi-gateway ruoyi-auth ruoyi-modules-system
}

# 根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
"base")
base
;;
"ui")
ui
;;
"service")
service
;;
"modules")
modules
;;
"all")
all
;;
*)
usage
;;
esac
41 changes: 0 additions & 41 deletions docker/copy.sh

This file was deleted.

31 changes: 28 additions & 3 deletions docker/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/sh
#!/bin/bash

export COMPOSE_PROJECT_NAME=ruoyi-cloud

# 使用说明,用来提示输入参数
usage() {
echo "Usage: sh 执行脚本.sh [port|base|modules|stop|rm]"
echo "Usage: sh 执行脚本.sh [port|base|modules|ui|service|stop|rm]"
exit 1
}

Expand All @@ -24,14 +26,28 @@ port(){
service firewalld restart
}

all() {
base
modules
}

# 启动基础环境(必须)
base(){
docker-compose up -d ruoyi-mysql ruoyi-redis ruoyi-nacos
}

# 启动程序模块(必须)
modules(){
docker-compose up -d ruoyi-nginx ruoyi-gateway ruoyi-auth ruoyi-modules-system
ui
service
}

ui(){
docker-compose up -d ruoyi-nginx
}

service(){
docker-compose up -d ruoyi-gateway ruoyi-auth ruoyi-modules-system
}

# 关闭所有环境/模块
Expand All @@ -55,12 +71,21 @@ case "$1" in
"modules")
modules
;;
"ui")
ui
;;
"service")
service
;;
"stop")
stop
;;
"rm")
rm
;;
"all")
all
;;
*)
usage
;;
Expand Down
29 changes: 25 additions & 4 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version : '3.8'
services:
ruoyi-nacos:
container_name: ruoyi-nacos
image: nacos/nacos-server
image: ruoyi-nacos
build:
context: ./nacos
environment:
Expand All @@ -18,7 +18,7 @@ services:
- ruoyi-mysql
ruoyi-mysql:
container_name: ruoyi-mysql
image: mysql:5.7
image: ruoyi-mysql
build:
context: ./mysql
ports:
Expand All @@ -40,7 +40,7 @@ services:
MYSQL_ROOT_PASSWORD: password
ruoyi-redis:
container_name: ruoyi-redis
image: redis
image: ruoyi-redis
build:
context: ./redis
ports:
Expand All @@ -51,7 +51,7 @@ services:
command: redis-server /home/ruoyi/redis/redis.conf
ruoyi-nginx:
container_name: ruoyi-nginx
image: nginx
image: ruoyi-nginx
build:
context: ./nginx
ports:
Expand All @@ -70,6 +70,9 @@ services:
build:
context: ./ruoyi/gateway
dockerfile: dockerfile
environment:
- SPRING_PROFILES_ACTIVE=docker
- RUOYI_NACOS_SERVER=ruoyi-nacos
ports:
- "8080:8080"
depends_on:
Expand All @@ -81,6 +84,9 @@ services:
build:
context: ./ruoyi/auth
dockerfile: dockerfile
environment:
- SPRING_PROFILES_ACTIVE=docker
- RUOYI_NACOS_SERVER=ruoyi-nacos
ports:
- "9200:9200"
depends_on:
Expand All @@ -92,6 +98,9 @@ services:
build:
context: ./ruoyi/modules/system
dockerfile: dockerfile
environment:
- SPRING_PROFILES_ACTIVE=docker
- RUOYI_NACOS_SERVER=ruoyi-nacos
ports:
- "9201:9201"
depends_on:
Expand All @@ -105,6 +114,9 @@ services:
build:
context: ./ruoyi/modules/gen
dockerfile: dockerfile
environment:
- SPRING_PROFILES_ACTIVE=docker
- RUOYI_NACOS_SERVER=ruoyi-nacos
ports:
- "9202:9202"
depends_on:
Expand All @@ -116,6 +128,9 @@ services:
build:
context: ./ruoyi/modules/job
dockerfile: dockerfile
environment:
- SPRING_PROFILES_ACTIVE=docker
- RUOYI_NACOS_SERVER=ruoyi-nacos
ports:
- "9203:9203"
depends_on:
Expand All @@ -127,6 +142,9 @@ services:
build:
context: ./ruoyi/modules/file
dockerfile: dockerfile
environment:
- SPRING_PROFILES_ACTIVE=docker
- RUOYI_NACOS_SERVER=ruoyi-nacos
ports:
- "9300:9300"
volumes:
Expand All @@ -136,5 +154,8 @@ services:
build:
context: ./ruoyi/visual/monitor
dockerfile: dockerfile
environment:
- SPRING_PROFILES_ACTIVE=docker
- RUOYI_NACOS_SERVER=ruoyi-nacos
ports:
- "9100:9100"
3 changes: 2 additions & 1 deletion docker/mysql/dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 基础镜像
FROM mysql:5.7
# for run on wsl2 see https://github.com/docker/for-win/issues/4824
FROM mysql:5.7.16
# author
MAINTAINER ruoyi

Expand Down
Loading