KCloud-Platform-IoT KCloud-Platform-IoT
首页
  • 开发手册

    • 组件【ai】
    • 组件【algorithm】
    • 组件【banner】
    • 组件【clickhouse】
    • 组件【core】
    • 组件【bom】
    • 组件【cors】
    • 组件【domain】
    • 组件【crypto】
    • 组件【data-cache】
    • 组件【dubbo】
    • 组件【elasticsearch】
    • 组件【excel】
    • 组件【extension】
    • 组件【flink】
    • 组件【grpc】
    • 组件【i18n】
    • 组件【idempotent】
    • 组件【influxdb】
    • 组件【kafka】
    • 组件【log】
    • 组件【lock】
    • 组件【mail】
    • 组件【log4j2】
    • 组件【mqtt】
    • 组件【mongodb】
    • 组件【mybatis-plus】
    • 组件【nacos】
    • 组件【netty】
    • 组件【openapi-doc】
    • 组件【openfeign】
    • 组件【oss】
    • 组件【prometheus】
    • 组件【rabbitmq】
    • 组件【rate-limiter】
    • 组件【reactor】
    • 组件【redis】
    • 组件【rocketmq】
    • 组件【ruleengine】
    • 组件【secret】
    • 组件【security】
    • 组件【sensitive】
    • 组件【sentinel】
    • 组件【sms】
    • 组件【snail-job】
    • 组件【spark】
    • 组件【starrocks】
    • 组件【statemachine】
    • 组件【storage】
    • 组件【tdengine】
    • 组件【tenant】
    • 组件【test】
    • 组件【trace】
    • 组件【xss】
    • 组件【shardingsphere】
  • 环境搭建

    • Centos7安装Mysql 8.0.33
    • Centos7安装Redis 7.0.11
    • Centos7安装RocketMQ 5.1.1
    • Centos7安装Jdk 17.0.7
    • Centos7安装Docker 23.0.6
    • Centos7安装Elasticsearch 8.6.2
    • Docker安装RabbitMQ 3.12.2
    • Docker安装Postgresql 16.1
    • Ubuntu20.04安装Docker
    • Ubuntu20.04忘记密码或指纹错误
  • 常用命令

    • Centos7常用命令
    • Centos7常用命令
  • 快速上手

    • 项目启动【dev环境】
    • 项目启动【test环境】
    • 项目启动【prod环境】
    • 更新日志
  • 前端指南

    • 前端启动
  • 后端指南

    • COLA代码规范
    • SSL证书
    • 一键修改项目模块
    • 一键生成项目骨架
    • 一键修改项目版本号
    • 一键跳过测试用例
    • 一键生成后端COLA代码
    • 分布式链路跟踪之ELK日志
    • 一键检查代码规范
    • 动态路由
  • 项目部署

    • 项目部署之镜像打包与推送
  • 其他

    • Java如何快速转Go
    • Go快速开发API
    • Vue快速开发Api
    • React快速开发Api
  • 文章

    • 物联网之对接MQTT最佳实践
    • 物联网之使用Vertx实现MQTT-Server最佳实践【响应式】
    • vue3+lime-echart各种图表使用【懒人专用,建议收藏】
    • 物联网之使用Vertx实现TCP最佳实践【响应式】
    • 物联网之使用Vertx实现HTTPWebSocket最佳实践【响应式】
    • 物联网之使用Vertx实现UDP最佳实践【响应式】
  • 儒学

    • 儒学摘抄(一)
  • 禅语

    • 禅语摘抄(一)
  • 诗词

    • 诗词摘抄(一)
  • 道法

    • 道法摘抄(一)
  • 养生

    • 养生摘抄(一)
  • 读后感

    • 读《强者,都是含泪奔跑的人》读后感
  • 修行

    • 修身/养生/情感
  • 觉悟

    • 觉悟日记(一)
赞助
项目课程 (opens new window)
GitHub (opens new window)
首页
  • 开发手册

    • 组件【ai】
    • 组件【algorithm】
    • 组件【banner】
    • 组件【clickhouse】
    • 组件【core】
    • 组件【bom】
    • 组件【cors】
    • 组件【domain】
    • 组件【crypto】
    • 组件【data-cache】
    • 组件【dubbo】
    • 组件【elasticsearch】
    • 组件【excel】
    • 组件【extension】
    • 组件【flink】
    • 组件【grpc】
    • 组件【i18n】
    • 组件【idempotent】
    • 组件【influxdb】
    • 组件【kafka】
    • 组件【log】
    • 组件【lock】
    • 组件【mail】
    • 组件【log4j2】
    • 组件【mqtt】
    • 组件【mongodb】
    • 组件【mybatis-plus】
    • 组件【nacos】
    • 组件【netty】
    • 组件【openapi-doc】
    • 组件【openfeign】
    • 组件【oss】
    • 组件【prometheus】
    • 组件【rabbitmq】
    • 组件【rate-limiter】
    • 组件【reactor】
    • 组件【redis】
    • 组件【rocketmq】
    • 组件【ruleengine】
    • 组件【secret】
    • 组件【security】
    • 组件【sensitive】
    • 组件【sentinel】
    • 组件【sms】
    • 组件【snail-job】
    • 组件【spark】
    • 组件【starrocks】
    • 组件【statemachine】
    • 组件【storage】
    • 组件【tdengine】
    • 组件【tenant】
    • 组件【test】
    • 组件【trace】
    • 组件【xss】
    • 组件【shardingsphere】
  • 环境搭建

    • Centos7安装Mysql 8.0.33
    • Centos7安装Redis 7.0.11
    • Centos7安装RocketMQ 5.1.1
    • Centos7安装Jdk 17.0.7
    • Centos7安装Docker 23.0.6
    • Centos7安装Elasticsearch 8.6.2
    • Docker安装RabbitMQ 3.12.2
    • Docker安装Postgresql 16.1
    • Ubuntu20.04安装Docker
    • Ubuntu20.04忘记密码或指纹错误
  • 常用命令

    • Centos7常用命令
    • Centos7常用命令
  • 快速上手

    • 项目启动【dev环境】
    • 项目启动【test环境】
    • 项目启动【prod环境】
    • 更新日志
  • 前端指南

    • 前端启动
  • 后端指南

    • COLA代码规范
    • SSL证书
    • 一键修改项目模块
    • 一键生成项目骨架
    • 一键修改项目版本号
    • 一键跳过测试用例
    • 一键生成后端COLA代码
    • 分布式链路跟踪之ELK日志
    • 一键检查代码规范
    • 动态路由
  • 项目部署

    • 项目部署之镜像打包与推送
  • 其他

    • Java如何快速转Go
    • Go快速开发API
    • Vue快速开发Api
    • React快速开发Api
  • 文章

    • 物联网之对接MQTT最佳实践
    • 物联网之使用Vertx实现MQTT-Server最佳实践【响应式】
    • vue3+lime-echart各种图表使用【懒人专用,建议收藏】
    • 物联网之使用Vertx实现TCP最佳实践【响应式】
    • 物联网之使用Vertx实现HTTPWebSocket最佳实践【响应式】
    • 物联网之使用Vertx实现UDP最佳实践【响应式】
  • 儒学

    • 儒学摘抄(一)
  • 禅语

    • 禅语摘抄(一)
  • 诗词

    • 诗词摘抄(一)
  • 道法

    • 道法摘抄(一)
  • 养生

    • 养生摘抄(一)
  • 读后感

    • 读《强者,都是含泪奔跑的人》读后感
  • 修行

    • 修身/养生/情感
  • 觉悟

    • 觉悟日记(一)
赞助
项目课程 (opens new window)
GitHub (opens new window)
  • 开发手册

    • 组件【ai】
    • 组件【algorithm】
    • 组件【banner】
    • 组件【clickhouse】
    • 组件【core】
    • 组件【bom】
    • 组件【cors】
    • 组件【domain】
    • 组件【crypto】
    • 组件【data-cache】
    • 组件【dubbo】
    • 组件【elasticsearch】
    • 组件【excel】
    • 组件【extension】
    • 组件【flink】
    • 组件【grpc】
    • 组件【i18n】
    • 组件【idempotent】
    • 组件【influxdb】
    • 组件【kafka】
    • 组件【log】
    • 组件【lock】
    • 组件【mail】
    • 组件【log4j2】
    • 组件【mqtt】
    • 组件【mongodb】
    • 组件【mybatis-plus】
    • 组件【nacos】
    • 组件【netty】
    • 组件【openapi-doc】
    • 组件【openfeign】
    • 组件【oss】
    • 组件【prometheus】
    • 组件【rabbitmq】
    • 组件【rate-limiter】
    • 组件【reactor】
    • 组件【redis】
    • 组件【rocketmq】
    • 组件【ruleengine】
    • 组件【secret】
    • 组件【security】
    • 组件【sensitive】
    • 组件【sentinel】
    • 组件【sms】
    • 组件【snail-job】
    • 组件【spark】
    • 组件【starrocks】
    • 组件【statemachine】
    • 组件【storage】
    • 组件【tdengine】
    • 组件【tenant】
    • 组件【test】
    • 组件【trace】
    • 组件【xss】
    • 组件【shardingsphere】
  • 环境搭建

    • Centos7安装Mysql 8.0.33
    • Centos7安装Redis 7.0.11
    • Centos7安装RocketMQ 5.1.1
    • Centos7安装Jdk 17.0.7
    • Centos7安装Docker 23.0.6
    • Docker安装RabbitMQ 3.12.2
    • Centos7安装Elasticsearch 8.6.2
    • Docker安装Postgresql 16.1
    • Ubuntu20.04安装Docker
    • Ubuntu20.04忘记密码或指纹错误
  • 常用命令

    • Centos7常用命令
    • Docker常用命令
  • 快速上手

    • 项目启动【dev环境】
    • 项目启动【test环境】
    • 项目启动【prod环境】
    • 更新日志
  • 前端指南

    • 前端启动
  • 后端指南

    • COLA代码规范
    • SSL证书
    • 一键修改项目模块
    • 一键生成项目骨架
    • 一键修改项目版本号
    • 一键跳过测试用例
    • 一键生成后端COLA代码
    • 分布式链路跟踪之ELK日志
    • 一键检查代码规范
    • 动态路由
    • OAuth2.1流程
  • 项目部署

    • 项目部署之镜像打包与推送
    • 其他

      • Java如何快速转Go
      • Go快速开发API
      • Vue快速开发Api
      • React快速开发Api
    • 文章

      • 物联网之对接MQTT最佳实践
      • 物联网之使用Vertx实现MQTT-Server最佳实践【响应式】
      • vue3+lime-echart各种图表使用【懒人专用,建议收藏】
      • 物联网之使用Vertx实现TCP最佳实践【响应式】
      • 物联网之使用Vertx实现HTTPWebSocket最佳实践【响应式】
      • 物联网之使用Vertx实现UDP最佳实践【响应式】
    • 指南
    • 项目部署
    KCloud-Platform-IoT
    2024-08-19
    目录

    项目部署之镜像打包与推送

    你好呀,我的老朋友!我是老寇,欢迎来到老寇云平台!

    话不多说,讲一讲项目部署之镜像打包与推送!

    # 安装插件

    <!-- 打包插件,将 Java 源代码编译为字节码(.class 文件) -->
    <plugins>
    	<plugin>
    		<groupId>org.apache.maven.plugins</groupId>
    		<artifactId>maven-compiler-plugin</artifactId>
    		<version>3.13.0</version>
    		<configuration>
    			<source>21</source>
    			<target>21</target>
    			<encoding>UTF-8</encoding>
    			<compilerArgs>
    				<!-- 关闭对不推荐使用的编译器选项的警告 -->
    				<arg>-Xlint:-options</arg>
    				<!--  启用对可变参数使用的警告 -->
    				<arg>-Xlint:varargs</arg>
    				<!-- 启用对使用原始类型raw types的警告 -->
    				<arg>-Xlint:rawtypes</arg>
    				<!-- 启用对未检查的操作的警告,比如未检查的类型转换 -->
    				<arg>-Xlint:unchecked</arg>
    				<!-- 启用对使用过时 API 的警告 -->
    				<arg>-Xlint:deprecation</arg>
    				<!-- 在编译的字节码中保留方法参数的名称,这对反射或序列化框架非常有用 -->
    				<arg>-parameters</arg>
    			</compilerArgs>
    		</configuration>
    	</plugin>
    
    	<!-- 专门用于 Spring Boot 应用的打包和运行,提供打包为可执行 JAR/WAR 文件的功能,还可以在开发过程中直接运行应用 -->
    	<plugin>
    		<groupId>org.springframework.boot</groupId>
    		<artifactId>spring-boot-maven-plugin</artifactId>
    		<version>3.3.2</version>
    		<configuration>
    			<finalName>${project.artifactId}</finalName>
    			<!-- main方法的地址 只需要修改这个地址-->
    			<mainClass>xxx.xxx.xxx.XxxApp</mainClass>
    		</configuration>
    		<executions>
    			<execution>
    				<goals>
    					<goal>repackage</goal>
    				</goals>
    			</execution>
    		</executions>
    	</plugin>
    
    	<!-- 执行Docker镜像的构建、推送和运行等操作 -->
    	<plugin>
    		<groupId>io.fabric8</groupId>
    		<artifactId>docker-maven-plugin</artifactId>
    		<version>0.45.0</version>
    		<configuration>
    			<!--Docker主机-->
    			<dockerHost>${docker.host}</dockerHost>
    			<!--Docker私库-->
    			<registry>${docker.registry}</registry>
    			<!-- 认证信息-->
    			<authConfig>
    				<push>
    					<username>${docker.username}</username>
    					<password>${docker.password}</password>
    				</push>
    			</authConfig>
    			<images>
    				<image>
    					<!-- 推送仓库/命名空间/仓库名称:镜像版本号-->
    					<name>${docker.registry}/${docker.namespace}/${project.artifactId}:${project.version}</name>
    					<build>
    						<tags>
    							<tag>${project.version}</tag>
    						</tags>
    						<!-- 指定dockerfile文件的位置-->
    						<dockerFile>${project.basedir}/Dockerfile</dockerFile>
    					</build>
    				</image>
    			</images>
    		</configuration>
    	</plugin>
    
    	<!-- profile对资源的操作 -->
    	<resources>
    		<!-- 打包的时候先去掉所有的配置文件 -->
    		<resource>
    			<directory>src/main/resources</directory>
    			<excludes>
    				<exclude>application*.yml</exclude>
    				<exclude>bootstrap*.yml</exclude>
    				<exclude>log4j2*.xml</exclude>
    				<exclude>*.json</exclude>
    				<exclude>*.properties</exclude>
    			</excludes>
    		</resource>
    		<!-- 添加需要包含的文件 -->
    		<resource>
    			<directory>src/main/resources</directory>
    			<!-- 是否替换yml或者properties里@xx@表示的maven properties属性值 -->
    			<filtering>true</filtering>
    			<!-- 在打包的时候,根据-P参数,加上需要的yml配置文件 -->
    			<includes>
    				<include>application.yml</include>
    				<include>application-${PROFILE-ACTIVE}.yml</include>
    				<include>bootstrap.yml</include>
    				<include>bootstrap-${PROFILE-ACTIVE}.yml</include>
    				<include>log4j2-${PROFILE-ACTIVE}.xml</include>
    				<include>init_router.json</include>
    				<include>log4j2.component.properties</include>
    			</includes>
    		</resource>
    	</resources>
    </plugins>
    

    # 注册阿里云仓库

    请自行百度

    # 项目打包

    # 配置docker和镜像仓库

    
    <properties>
    	<docker.host>tcp://127.0.0.1:2375</docker.host>
    	<docker.registry>registry.cn-shenzhen.aliyuncs.com</docker.registry>
    	<docker.namespace>koushenhai</docker.namespace>
    	<docker.username>username</docker.username>
    	<docker.password>password</docker.password>
    </properties>
    

    # 打包

    # 切换环境

    切换到prod环境[记得刷新maven]

    # 打包项目
    # 打包
    mvn clean install -P prod
    

    # 推送

    # 启动docker

    自行启动,不过需要注意一下,因某些原因docker暂不能用,需要科学上网才行

    作者的docker镜像源

    {
    	"registry-mirrors": [
    		"https://dockerproxy.com",
    		"https://docker.mirrors.ustc.edu.cn",
    		"https://docker.nju.edu.cn",
    		"https://docker.m.daocloud.io"
    	]
    }
    
    # 推送镜像

    以Nacos为例

    按此步骤依次打包sentinel/snail job/gateway/monitor/auth/admin/logstash

    # 部署

    找到项目的部署文件夹

    注意:需要将如下文件夹拖到到新建文件夹

    # 注意需要先启动postgresql,然后运行sql脚本,再重新启动docker
    docker-compose up -d
    

    我是老寇,我们下次再见啦!

    上次更新: 5/21/2025, 5:17:33 PM
    OAuth2.1流程
    Java如何快速转Go

    ← OAuth2.1流程 Java如何快速转Go→

    Theme by Vdoing | Copyright © 2022-2025 laokou | Apache 2.0 License
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式