企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 55.4 Boxfuse和Amazon Web Services ### 55.4 Boxfuse和Amazon Web Services [Boxfuse](https://boxfuse.com/)的工作机制是将你的Spring Boot可执行jar或war转换进一个最小化的VM镜像,该镜像不需改变就能部署到VirtualBox或AWS。Boxfuse深度集成Spring Boot并使用你的Spring Boot配置文件自动配置端口和健康检查URLs,它将该信息用于产生的镜像及它提供的所有资源(实例,安全分组,可伸缩的负载均衡等)。 一旦创建一个[Boxfuse account](https://console.boxfuse.com/),并将它连接到你的AWS账号,安装最新版Boxfuse客户端,你就能按照以下操作将Spring Boot应用部署到AWS(首先要确保应用被Maven或Gradle构建过,比如`mvn clean package`): ``` $ boxfuse run myapp-1.0.jar -env=prod ``` 更多选项可查看[`boxfuse run`文档](https://boxfuse.com/docs/commandline/run.html),如果当前目录存在一个[boxfuse.conf](https://boxfuse.com/docs/commandline/#configuration)文件,Boxfuse将使用它。 **注** 如果你的可执行jar或war包含[`application-boxfuse.properties`](https://boxfuse.com/docs/payloads/springboot.html#configuration)文件,Boxfuse默认在启动时会激活一个名为`boxfuse`的Spring profile,然后在该profile包含的属性基础上构建自己的配置。 此刻`boxfuse`将为你的应用创建一个镜像并上传到AWS,然后配置并启动需要的资源: ``` Fusing Image for myapp-1.0.jar ... Image fused in 00:06.838s (53937 K) -> axelfontaine/myapp:1.0 Creating axelfontaine/myapp ... Pushing axelfontaine/myapp:1.0 ... Verifying axelfontaine/myapp:1.0 ... Creating Elastic IP ... Mapping myapp-axelfontaine.boxfuse.io to 52.28.233.167 ... Waiting for AWS to create an AMI for axelfontaine/myapp:1.0 in eu-central-1 (this may take up to 50 seconds) ... AMI created in 00:23.557s -> ami-d23f38cf Creating security group boxfuse-sg_axelfontaine/myapp:1.0 ... Launching t2.micro instance of axelfontaine/myapp:1.0 (ami-d23f38cf) in eu-central-1 ... Instance launched in 00:30.306s -> i-92ef9f53 Waiting for AWS to boot Instance i-92ef9f53 and Payload to start at http://52.28.235.61/ ... Payload started in 00:29.266s -> http://52.28.235.61/ Remapping Elastic IP 52.28.233.167 to i-92ef9f53 ... Waiting 15s for AWS to complete Elastic IP Zero Downtime transition ... Deployment completed successfully. axelfontaine/myapp:1.0 is up and running at http://myapp-axelfontaine.boxfuse.io/ ``` 你的应用现在应该已经在AWS上启动并运行了。 这里有篇[在EC2部署Spring Boot应用](https://boxfuse.com/blog/spring-boot-ec2.html)的博客,Boxfuse官网也有[Boxfuse集成Spring Boot文档](https://boxfuse.com/docs/payloads/springboot.html),你可以拿来作为参考。