Browse Source

🎉 docker构建工具更换为fabric

training
smallchill 2 years ago
parent
commit
6f0454cf84
  1. 14
      blade-gateway/pom.xml
  2. 14
      blade-ops/blade-xxljob-admin/pom.xml
  3. 14
      blade-ops/blade-xxljob/pom.xml
  4. 14
      blade-service/blade-demo/pom.xml
  5. 35
      doc/docker/README.md
  6. 6
      doc/nacos/blade-prod.yaml
  7. 6
      doc/nacos/blade-test.yaml
  8. 55
      pom.xml
  9. 2
      script/docker/app/.env

14
blade-gateway/pom.xml

@ -78,18 +78,10 @@
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<username>${docker.username}</username>
<password>${docker.password}</password>
<repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
<skip>false</skip>
<skip>${docker.fabric.skip}</skip>
</configuration>
</plugin>
<plugin>

14
blade-ops/blade-xxljob-admin/pom.xml

@ -92,18 +92,10 @@
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<username>${docker.username}</username>
<password>${docker.password}</password>
<repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
<skip>false</skip>
<skip>${docker.fabric.skip}</skip>
</configuration>
</plugin>
<plugin>

14
blade-ops/blade-xxljob/pom.xml

@ -37,18 +37,10 @@
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<username>${docker.username}</username>
<password>${docker.password}</password>
<repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
<skip>false</skip>
<skip>${docker.fabric.skip}</skip>
</configuration>
</plugin>
<plugin>

14
blade-service/blade-demo/pom.xml

@ -57,18 +57,10 @@
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<username>${docker.username}</username>
<password>${docker.password}</password>
<repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
<skip>false</skip>
<skip>${docker.fabric.skip}</skip>
</configuration>
</plugin>
<plugin>

35
doc/docker/README.md

@ -4,9 +4,9 @@
```
<servers>
<server>
<id>192.168.0.157</id>
<id>192.168.0.188</id>
<username>admin</username>
<password>Harbor12345</password>
<password>admin12345</password>
<configuration>
<email>smallchill@163.com</email>
</configuration>
@ -14,13 +14,13 @@
</servers>
<pluginGroups>
<pluginGroup>com.spotify</pluginGroup>
<pluginGroup>io.fabric8</pluginGroup>
</pluginGroups>
```
### 2. docker开启远程访问
如果没有远程访问,会报 `Connect to 192.168.0.157:2375 [/192.168.0.157] failed: Connection refused: connect`
如果没有远程访问,会报 `Connect to 192.168.0.188:2375 [/192.168.0.188] failed: Connection refused: connect`
在`/usr/lib/systemd/system/docker.service`,配置远程访问。主要是在[Service]这个部分,加上下面两个参数:
@ -49,7 +49,7 @@ ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
```
{
"registry-mirrors": ["https://3dse7md.mirror.aliyuncs.com"],
"insecure-registries":["192.168.0.157"]
"insecure-registries":["192.168.0.188"]
}
```
@ -59,18 +59,10 @@ ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<username>${docker.username}</username>
<password>${docker.password}</password>
<repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
<skip>false</skip>
<skip>${docker.fabric.skip}</skip>
</configuration>
</plugin>
</plugins>
@ -80,9 +72,9 @@ ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
### 5. 在每个需要构建子项目的根目录下加入Dockerfile,内容可参考如下
```
FROM adoptopenjdk/openjdk8-openj9:alpine-slim
FROM bladex/alpine-java:openjdk8-openj9_cn_slim
MAINTAINER smallchill@163.com
MAINTAINER bladejava@qq.com
RUN mkdir -p /blade/gateway
@ -100,10 +92,15 @@ CMD ["--spring.profiles.active=test"]
### 6. 在工程根目录的docker-compose.yml下加入配置,内容可参考如下
```
blade-gateway:
image: "${REGISTER}/blade/blade-gateway:${TAG}"
image: "${REGISTER}/blade-gateway:${TAG}"
ports:
- 80:80
networks:
blade_net:
ipv4_address: 192.168.2.1
```
### 7. 一切配置完毕,采用fabric插件命令执行构建推送:
```
mvn clean package docker:build docker:push
```

6
doc/nacos/blade-prod.yaml

@ -4,7 +4,7 @@ spring:
##redis 单机环境配置
##将docker脚本部署的redis服务映射为宿主机ip
##生产环境推荐使用阿里云高可用redis服务并设置密码
host: 192.168.0.157
host: 192.168.0.188
port: 3379
password:
database: 0
@ -34,10 +34,10 @@ blade:
enabled: false
##将docker脚本部署的redis服务映射为宿主机ip
##生产环境推荐使用阿里云高可用redis服务并设置密码
address: redis://192.168.0.157:3379
address: redis://192.168.0.188:3379
#通用开发生产环境数据库地址(特殊情况可在对应的子工程里配置覆盖)
datasource:
prod:
url: jdbc:mysql://192.168.0.157:3306/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
url: jdbc:mysql://192.168.0.188:3306/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
username: root
password: root

6
doc/nacos/blade-test.yaml

@ -3,7 +3,7 @@ spring:
redis:
##redis 单机环境配置
##将docker脚本部署的redis服务映射为宿主机ip
host: 192.168.0.157
host: 192.168.0.188
port: 3379
password:
database: 0
@ -32,10 +32,10 @@ blade:
##是否启用分布式锁
enabled: false
##将docker脚本部署的redis服务映射为宿主机ip
address: redis://192.168.0.157:3379
address: redis://192.168.0.188:3379
#通用开发生产环境数据库地址(特殊情况可在对应的子工程里配置覆盖)
datasource:
test:
url: jdbc:mysql://192.168.0.157:3306/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
url: jdbc:mysql://192.168.0.188:3306/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
username: root
password: root

55
pom.xml

@ -19,13 +19,13 @@
<flowable.version>6.4.2</flowable.version>
<dubbo.version>2.7.8</dubbo.version>
<!-- 推荐使用Harbor -->
<docker.registry.url>192.168.0.157</docker.registry.url>
<docker.registry.host>http://${docker.registry.url}:2375</docker.registry.host>
<!-- Docker仓库服务配置 -->
<docker.registry.url>192.168.0.188</docker.registry.url>
<docker.username>admin</docker.username>
<docker.password>Harbor12345</docker.password>
<docker.password>admin12345</docker.password>
<docker.namespace>blade</docker.namespace>
<docker.plugin.version>1.4.13</docker.plugin.version>
<docker.fabric.skip>false</docker.fabric.skip>
<docker.fabric.version>0.42.0</docker.fabric.version>
</properties>
<modules>
@ -121,29 +121,29 @@
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.fabric.version}</version>
<configuration>
<username>${docker.username}</username>
<password>${docker.password}</password>
<repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<skip>true</skip>
<authConfig>
<username>${docker.username}</username>
<password>${docker.password}</password>
</authConfig>
<registry>${docker.registry.url}</registry>
<images>
<image>
<name>${docker.namespace}/${project.build.finalName}:${project.version}</name>
<alias>${project.name}</alias>
<build>
<dockerFile>${project.basedir}/Dockerfile</dockerFile>
</build>
</image>
</images>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
<JAR_FILE>${basedir}/target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
<!--子服务添加如下配置,运行 mvn deploy 命令便会自动打包镜像-->
<!--<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>-->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -168,13 +168,6 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>

2
script/docker/app/.env

@ -1,2 +1,2 @@
REGISTER=192.168.0.157/blade
REGISTER=192.168.0.188/blade
TAG=3.1.0.RELEASE

Loading…
Cancel
Save