Skip to content

Commit

Permalink
修复 mac 本地部署遇到的 bug (#54)
Browse files Browse the repository at this point in the history
* fix jar no with dependencies

* 完善Docker-compose部署 (#53)

* fix jar no with dependencies (#52)

* 完善Docker-compose部署

---------

Co-authored-by: BanTanger <[email protected]>
Co-authored-by: haoran.tian <[email protected]>

* fix errors in docker-compose and properties

* fix errors in docker-compose and properties

---------

Co-authored-by: 田浩然 <[email protected]>
Co-authored-by: haoran.tian <[email protected]>
  • Loading branch information
3 people committed Sep 18, 2023
1 parent 3c6064a commit e822705
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 39 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@
*.njsproj
*.sln
.DS_Store
/docker/mysql/data/
/docker/redis/data/
/logs/
5 changes: 4 additions & 1 deletion copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ echo ">>>>>>>>>>>>>>>>>"
jar_files=(
"im-domain/target/im-domain-1.0-SNAPSHOT.jar"
"im-message-store/target/im-message-store-1.0-SNAPSHOT.jar"
"im-tcp/target/im-tcp-1.0-SNAPSHOT.jar"
"im-tcp/target/im-tcp-1.0-SNAPSHOT-jar-with-dependencies.jar"
)

for index in "${!jar_files[@]}"; do
target_file="${target_directories[$index]}/jar/$(basename "${jar_files[$index]}")"
target_file_without_version="${target_directories[$index]}/jar/$(basename "${jar_files[$index]}" "-1.0-SNAPSHOT.jar").jar"
if [[ "${jar_files[$index]}" == *"jar-with-dependencies.jar" ]]; then
target_file_without_version="${target_directories[$index]}/jar/$(basename "${jar_files[$index]}" "-1.0-SNAPSHOT-jar-with-dependencies.jar").jar"
fi
echo "开始复制 ${jar_files[$index]} .."
cp "${jar_files[$index]}" "$target_file"
mv "$target_file" "$target_file_without_version"
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
# MySQL 容器
im-mysql:
container_name: im-mysql
image: mysql:8.0.11
image: mysql:8.0.33
build:
context: ./docker/mysql
restart: always
Expand Down Expand Up @@ -151,3 +151,4 @@ services:

networks:
im-network:
driver: host
2 changes: 1 addition & 1 deletion docker/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 基础镜像
FROM mysql:8.0.11
FROM mysql:8.0.33

# author
MAINTAINER BanTanger
Expand Down
2 changes: 1 addition & 1 deletion im-domain/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ COPY ./jar/im-domain.jar /opt/application/im-domain.jar
COPY application-docker.yml /opt/application/application.yml
COPY logback-spring.xml /opt/application/logback-spring.xml

ENTRYPOINT ["java", "-jar" ,"/opt/application/im-domain.jar"]
ENTRYPOINT ["java", "-jar" ,"/opt/application/im-domain.jar", "--logging.config=/opt/application/logback-spring.xml"]
14 changes: 7 additions & 7 deletions im-domain/src/main/resources/application-docker.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
server:
port: 8000
port: 18000

spring:
profiles:
active: dev
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
password: 123456
url: jdbc:mysql://127.0.0.1:3306/im_core?serverTimezone=UTC&useSSL=false&characterEncoding=UTF8
password: whalesharkim
url: jdbc:mysql://im-mysql:3306/im_core?serverTimezone=UTC&useSSL=false&characterEncoding=UTF8&allowPublicKeyRetrieval=true
username: root
# redis
redis:
host: 127.0.0.1
host: im-redis
port: 6379
jedis:
pool:
Expand All @@ -22,9 +22,9 @@ spring:
password: whalesharkim
# rabbitmq
rabbitmq:
host: localhost
host: im-rabbitmq
port: 5672
addresses: localhost
addresses: im-rabbitmq
username: admin
password: admin

Expand All @@ -33,7 +33,7 @@ spring:

appconfig:
privateKey: bantanger
zkAddr: 127.0.0.1:2181 # zk 连接地址
zkAddr: im-zookeeper:2181 # zk 连接地址
zkConnectTimeOut: 5000 # zk 超时时间
imRouteModel: 3 # 路由策略 1.轮询 2.随机 3.一致性hash
consistentHashModel: 1 # 一致性哈希底层调用数据结构 1.TreeMap 2.自定义 Map 3.待扩展
Expand Down
6 changes: 3 additions & 3 deletions im-domain/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ spring:
active: dev
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
password: 123456
url: jdbc:mysql://127.0.0.1:3306/im_core?serverTimezone=UTC&useSSL=false&characterEncoding=UTF8
password: whalesharkim
url: jdbc:mysql://127.0.0.1:3306/im_core?serverTimezone=UTC&useSSL=false&characterEncoding=UTF8&allowPublicKeyRetrieval=true
username: root
# redis
redis:
Expand All @@ -19,7 +19,7 @@ spring:
max-idle: 100
max-wait: 1000
min-idle: 10
password:
password: whalesharkim
# rabbitmq
rabbitmq:
host: localhost
Expand Down
2 changes: 1 addition & 1 deletion im-message-store/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ COPY ./jar/im-message-store.jar /opt/application/im-message-store.jar
COPY application-docker.yml /opt/application/application.yml
COPY logback-spring.xml /opt/application/logback-spring.xml

ENTRYPOINT ["java", "-jar" ,"/opt/application/im-message-store.jar"]
ENTRYPOINT ["java", "-jar" ,"/opt/application/im-message-store.jar", "--logging.config=/opt/application/logback-spring.xml"]
20 changes: 12 additions & 8 deletions im-message-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,20 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.bantanger.im.message.Application</mainClass>
</manifest>
</archive>
<!-- 指定该Main Class为全局的唯一入口 -->
<mainClass>com.bantanger.im.message.Application</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
10 changes: 5 additions & 5 deletions im-message-store/src/main/resources/application-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ spring:
active: dev
datasource:
driver-class-name: com.mysql.jdbc.Driver
password: 123456
url: jdbc:mysql://127.0.0.1:3306/im_core?serverTimezone=UTC&useSSL=false&characterEncoding=UTF8
password: whalesharkim
url: jdbc:mysql://im-mysql:3306/im_core?serverTimezone=UTC&useSSL=false&characterEncoding=UTF8&allowPublicKeyRetrieval=true
username: root

redis:
host: 127.0.0.1
host: im-redis
port: 6379
jedis:
pool:
Expand All @@ -21,9 +21,9 @@ spring:
min-idle: 10
password: whalesharkim
rabbitmq:
host: localhost
host: im-rabbitmq
port: 5672
addresses: localhost
addresses: im-rabbitmq
username: admin
password: admin
# virtual-host:
Expand Down
4 changes: 2 additions & 2 deletions im-message-store/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ spring:
active: dev
datasource:
driver-class-name: com.mysql.jdbc.Driver
password: 123456
url: jdbc:mysql://127.0.0.1:3306/im_core?serverTimezone=UTC&useSSL=false&characterEncoding=UTF8
password: whalesharkim
url: jdbc:mysql://127.0.0.1:3306/im_core?serverTimezone=UTC&useSSL=false&characterEncoding=UTF8&allowPublicKeyRetrieval=true
username: root

redis:
Expand Down
2 changes: 1 addition & 1 deletion im-tcp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar</descriptorRef>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
Expand Down
2 changes: 1 addition & 1 deletion im-tcp/src/main/resources/WebSocket.html
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@
//如果浏览器支持WebSocket
if (window.WebSocket) {
//参数就是与服务器连接的地址
socket = new WebSocket("ws://localhost:19001/ws");
socket = new WebSocket("ws://localhost:19002/ws");
//客户端收到服务器消息的时候就会执行这个回调方法
socket.onmessage = function (event) {
var ta = document.getElementById("responseText");
Expand Down
6 changes: 3 additions & 3 deletions im-tcp/src/main/resources/config-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ im:
poolConnTimeout: 3000 # 连接超时时间(秒)
poolSize: 10 # 连接池大小
single: #redis单机配置
address: 127.0.0.1:6379
address: im-redis:6379

rabbitmq:
host: 127.0.0.1
host: im-rabbitmq
port: 5672
virtualHost: /
userName: admin
password: admin

zkConfig:
zkAddr: 127.0.0.1:2181
zkAddr: im-zookeeper:2181
zkConnectTimeOut: 5000
6 changes: 3 additions & 3 deletions im-tcp/src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
im:
tcpPort: 9001
tcpPort: 19001
webSocketPort: 19002
bossThreadSize: 1
workThreadSize: 8
heartBeatTime: 3000 # 心跳超时时间 单位毫秒
brokerId: 1001
logicUrl: http://127.0.0.1:8000/v1 # Feign RPC 调用业务层
logicUrl: http://localhost:18000/v1 # Feign RPC 调用业务层
loginModel: 3
# 多端同步模式: 1 只允许一端在线,手机/电脑/web 踢掉除了本 client+imei 的设备
# 2 允许手机/电脑的一台设备 + web 在线 踢掉除了本 client+imei 的非 web 端设备
Expand All @@ -15,7 +15,7 @@ im:
redis:
mode: single # 单机模式:single 哨兵式:sentinel 集群模式:cluster
database: 0
password:
password: whalesharkim
timeout: 3000 # 超时时间
poolMinIdle: 4 #最小空闲数
poolConnTimeout: 3000 # 连接超时时间(秒)
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.77.Final</version>
<version>4.1.94.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<version>4.1.94.Final</version>
<classifier>osx-aarch_64</classifier>
</dependency>
<!-- commons-lang3 -->
<dependency>
Expand Down

0 comments on commit e822705

Please sign in to comment.