Skip to content

Commit

Permalink
feat/添加通过docker-compose 启动配置
Browse files Browse the repository at this point in the history
  • Loading branch information
freestylefly committed May 24, 2024
1 parent 4aa2091 commit f0a7782
Show file tree
Hide file tree
Showing 108 changed files with 606 additions and 204 deletions.
6 changes: 0 additions & 6 deletions docker/Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions docker/Dockerfile.pre

This file was deleted.

6 changes: 0 additions & 6 deletions docker/Dockerfile.prod

This file was deleted.

6 changes: 0 additions & 6 deletions docker/Dockerfile.test

This file was deleted.

44 changes: 44 additions & 0 deletions docker/copy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh

# 复制项目的文件到对应docker路径,便于一键生成镜像。
usage() {
echo "Usage: sh copy.sh"
exit 1
}


# copy sql
echo "begin copy sql "
cp ../sql/pmhub_20240305.sql ./mysql/db
cp ../sql/pmhub_nacos_20240423.sql ./mysql/db

# copy html
echo "begin copy html "
cp -r ../pmhub-ui/dist/** ./nginx/html/dist


# copy jar
echo "begin copy pmhub-gateway "
cp ../pmhub-gateway/target/pmhub-gateway.jar ./pmhub/gateway/jar

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

echo "begin copy pmhub-monitor "
cp ../pmhub-monitor/target/pmhub-monitor.jar ./pmhub/monitor/jar

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

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

echo "begin copy pmhub-gen "
cp ../pmhub-modules/pmhub-gen/target/pmhub-gen.jar ./pmhub/modules/gen/jar

echo "begin copy pmhub-project "
cp ../pmhub-modules/pmhub-project/target/pmhub-project.jar ./pmhub/modules/project/jar

echo "begin copy pmhub-workflow "
cp ../pmhub-modules/pmhub-workflow/target/pmhub-workflow.jar ./pmhub/modules/workflow/jar

67 changes: 67 additions & 0 deletions docker/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh

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

# 开启所需端口
port(){
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-port=8080/tcp --permanent
firewall-cmd --add-port=8848/tcp --permanent
firewall-cmd --add-port=9848/tcp --permanent
firewall-cmd --add-port=9849/tcp --permanent
firewall-cmd --add-port=6379/tcp --permanent
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --add-port=9100/tcp --permanent
firewall-cmd --add-port=9200/tcp --permanent
firewall-cmd --add-port=9201/tcp --permanent
firewall-cmd --add-port=9202/tcp --permanent
firewall-cmd --add-port=9203/tcp --permanent
firewall-cmd --add-port=9300/tcp --permanent
service firewalld restart
}

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

# 启动程序模块(必须)
modules(){
docker-compose up -d pmhub-nginx pmhub-gateway pmhub-auth pmhub-system pmhub-project pmhub-workflow
}

# 关闭所有环境/模块
stop(){
docker-compose stop
}

# 删除所有环境/模块
rm(){
docker-compose rm
}

# 根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
"port")
port
;;
"base")
base
;;
"modules")
modules
;;
"stop")
stop
;;
"rm")
rm
;;
*)
usage
;;
esac
157 changes: 157 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
version : '3.8'
services:
pmhub-nacos:
container_name: pmhub-nacos
image: nacos/nacos-server
build:
context: ./nacos
environment:
- MODE=standalone
volumes:
- ./nacos/logs/:/home/nacos/logs
- ./nacos/conf/application.properties:/home/nacos/conf/application.properties
ports:
- "8848:8848"
- "9848:9848"
- "9849:9849"
depends_on:
- pmhub-mysql
pmhub-mysql:
container_name: pmhub-mysql
image: mysql:5.7
build:
context: ./mysql
ports:
- "3306:3306"
volumes:
- ./mysql/conf:/etc/mysql/conf.d
- ./mysql/logs:/logs
- ./mysql/data:/var/lib/mysql
command: [
'mysqld',
'--innodb-buffer-pool-size=80M',
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_unicode_ci',
'--default-time-zone=+8:00',
'--lower-case-table-names=1'
]
environment:
MYSQL_DATABASE: 'ry-cloud'
MYSQL_ROOT_PASSWORD: password
pmhub-redis:
container_name: pmhub-redis
image: redis
build:
context: ./redis
ports:
- "6379:6379"
volumes:
- ./redis/conf/redis.conf:/home/pmhub/redis/redis.conf
- ./redis/data:/data
command: redis-server /home/pmhub/redis/redis.conf
pmhub-nginx:
container_name: pmhub-nginx
image: nginx
build:
context: ./nginx
ports:
- "80:80"
volumes:
- ./nginx/html/dist:/home/pmhub/projects/pmhub-ui
- ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/logs:/var/log/nginx
- ./nginx/conf.d:/etc/nginx/conf.d
depends_on:
- pmhub-gateway
links:
- pmhub-gateway
pmhub-gateway:
container_name: pmhub-gateway
build:
context: pmhub/gateway
dockerfile: dockerfile
ports:
- "8080:8080"
depends_on:
- pmhub-redis
links:
- pmhub-redis
ruoyi-auth:
container_name: pmhub-auth
build:
context: pmhub/auth
dockerfile: dockerfile
ports:
- "9200:9200"
depends_on:
- pmhub-redis
links:
- pmhub-redis
pmhub-modules-system:
container_name: pmhub-system
build:
context: pmhub/modules/system
dockerfile: dockerfile
ports:
- "9201:9201"
depends_on:
- pmhub-redis
- pmhub-mysql
links:
- pmhub-redis
- pmhub-mysql
pmhub-modules-gen:
container_name: pmhub-gen
build:
context: pmhub/modules/gen
dockerfile: dockerfile
ports:
- "9202:9202"
depends_on:
- pmhub-mysql
links:
- pmhub-mysql
pmhub-modules-job:
container_name: pmhub-job
build:
context: pmhub/modules/job
dockerfile: dockerfile
ports:
- "9203:9203"
depends_on:
- pmhub-mysql
links:
- pmhub-mysql

pmhub-modules-project:
container_name: pmhub-project
build:
context: pmhub/modules/project
dockerfile: dockerfile
ports:
- "9203:9203"
depends_on:
- pmhub-mysql
links:
- pmhub-mysql

pmhub-modules-workflow:
container_name: pmhub-workflow
build:
context: pmhub/modules/workflow
dockerfile: dockerfile
ports:
- "9203:9203"
depends_on:
- pmhub-mysql
links:
- pmhub-mysql


pmhub-monitor:
container_name: pmhub-monitor
build:
context: pmhub/monitor/monitor
dockerfile: pmhub/monitor/dockerfile
ports:
- "9100:9100"
1 change: 1 addition & 0 deletions docker/mysql/db/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
���sqlĿ¼�µ����нű�������docker�Զ�ִ�С�
7 changes: 7 additions & 0 deletions docker/mysql/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 基础镜像
FROM mysql:5.7
# author
MAINTAINER canghe

# 执行sql脚本
ADD ./db/*.sql /docker-entrypoint-initdb.d/
32 changes: 32 additions & 0 deletions docker/nacos/conf/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://127.0.0.1:3306/pmhub-nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user=root
db.password=123456

nacos.naming.empty-service.auto-clean=true
nacos.naming.empty-service.clean.initial-delay-ms=50000
nacos.naming.empty-service.clean.period-time-ms=30000

management.endpoints.web.exposure.include=*

management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false

server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i

server.tomcat.basedir=file:.

nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**

nacos.core.auth.system.type=nacos
nacos.core.auth.enabled=false
nacos.core.auth.default.token.expire.seconds=18000
nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
nacos.core.auth.caching.enabled=true
nacos.core.auth.enable.userAgentAuthWhite=false
nacos.core.auth.server.identity.key=serverIdentity
nacos.core.auth.server.identity.value=security

nacos.istio.mcp.server.enabled=false
7 changes: 7 additions & 0 deletions docker/nacos/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 基础镜像
FROM nacos/nacos-server
# author
MAINTAINER canghe

# 复制conf文件到路径
COPY ./conf/application.properties /home/nacos/conf/application.properties
41 changes: 41 additions & 0 deletions docker/nginx/conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

server {
listen 80;
server_name localhost;

location / {
root /home/ruoyi/projects/ruoyi-ui;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}

location /prod-api/{
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://ruoyi-gateway:8080/;
}

# 避免actuator暴露
if ($request_uri ~ "/actuator") {
return 403;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
Loading

0 comments on commit f0a7782

Please sign in to comment.