-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modified guide to enable Spring Boot Docker Compose support #43
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I wrote some content in this guide that I hope will be the foundation for other guide updates. It would be great to get a review from a few:
|
It makes sense to use Docker Compose for our Data-related guides requiring a running database such as Neo4j, MongoDB, Cassandra. |
@artembilan @robertmcnees I am wondering if we could use an annotation-based programming model variant that allows to express that |
Yes, that would be easier and simple, but if you follow this guide by itself, it talks exactly about such a POJO approach via Does it make sense? |
@sdeleuze @artembilan I can remove the sections on building native if it doesn't fit with the guide. Native is in this guide because I'm experimenting with a new common format for building all of our guides. I know this PR doesn't reference that file but the text should be the same. I plan to update this PR or have a new one to include the shared instructions. This is one of the first Guides I'm experimenting with the new format. |
README.adoc
Outdated
With a Docker environment enabled, you can execute the application with the command `docker run --network container:guide-rabbit docker.io/library/{build_name}:{build_version}` | ||
|
||
NOTE: The `--network` flag tells Docker to attach our guide container to the existing network that our RabbitMQ container is using. | ||
More information about this can be found in the https://docs.docker.com/network/#container-networks[Docker documentation^]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change More information about this can be found
to You can find more information
README.adoc
Outdated
|
||
=== Native Image Support | ||
|
||
Spring Boot also supports https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.introducing-graalvm-native-images[compilation to a native image^], provided you have a GraalVM distribution on your machine. To create a https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.developing-your-first-application.native-build-tools.gradle[native image with Gradle^] using Native Build Tools, first make sure that your Gradle build contains a `plugins` block that includes `org.graalvm.buildtools.native`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the period at the end to a colon
README.adoc
Outdated
... | ||
---- | ||
|
||
Additionally, you need to provide a https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.advanced.custom-hints[custom hint^]. Add a new class `MyRuntimeHints` that implements `RuntimeHintsRegistrar`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the period at the end to a colon
README.adoc
Outdated
---- | ||
==== | ||
|
||
You can then run the command `./gradlew nativeCompile` to generate a native image. When the build completes, you will be able to run the code with a near instantaneous start up time by executing the command `build/native/nativeCompile/{build_name}`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to:
You can then run the ./gradlew nativeCompile
command to generate a native image. When the build completes, you can run the code with a near-instantaneous startup time by running the build/native/nativeCompile/{build_name}
command.
README.adoc
Outdated
|
||
You can then run the command `./gradlew nativeCompile` to generate a native image. When the build completes, you will be able to run the code with a near instantaneous start up time by executing the command `build/native/nativeCompile/{build_name}`. | ||
|
||
You can also create a https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.developing-your-first-application.buildpacks[Native Image using Buildpacks^]. Provided that the Gradle `plugins` block contains `org.graalvm.buildtools.native`, you can generate a native image by running the task `./gradlew bootBuildImage`. Once the build completes, you can start your application with the command `docker run --network container:guide-rabbit docker.io/library/{build_name}:{build_version}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to:
You can also create a https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.developing-your-first-application.buildpacks[Native Image using Buildpacks^]. Provided that the Gradle plugins
block contains org.graalvm.buildtools.native
, you can generate a native image by running the ./gradlew bootBuildImage
task. Once the build completes, you can start your application with the docker run --network container:guide-rabbit docker.io/library/{build_name}:{build_version}
command.
@artembilan If this is our official RabbitMQ guide, and unless there is an historical context I miss, I think I am still in favor of updating it to use the annotation-based programming model which seems more elegant and modern from a programming model perspective, avoid using string based reflection (which we try to really avoid these days) and works out-of-the-box with native. It is ok to document native hints when needed, but I would keep that for use cases where we don't have the choice by design like HTTP client serialization. @robertmcnees I think that's a great idea to introduce native support in our guides if we can concentrate the native specific instructions in the native section minimized by default to avoid leaking uneeded complexity to regular JVM users. |
Thanks @Buzzardo. In addition to making the requested changes in this PR, I also updated this shared file with the same changes. My intent is that the |
@artembilan @sdeleuze For now, what do you think about removing the instructions for native compilation (and custom hints) entirely from this PR? I can create another Issue in this repository for adding native support. In hindsight, I should have kept this PR more focused to Docker Compose support and changed the @sdeleuze My end goal is to have all guides have instructions on native support, provided that no custom hints are required. In a more straightforward example, I did a proof of concept with the Getting Started guide that looks to a Shared File. |
@robertmcnees Works for me, let's do it in 2 steps. |
Sounds like a plan!
Pay attention to that |
This PR updates the guide by simplifying access on an external dependency, RabbitMQ. The original guide was written before Spring Boot introduced support for Docker Compose. The user can now simply run the application and allow Spring Boot to find the
compose.yaml
file automatically. This simplifies the steps and external dependencies for new users.The majority of the guide remains unchanged other than how to build and execute the final product. In pursuit of that goal, several items were changed.
spring-boot-docker-compose
dependency (4 files in total -build.gradle
andpom.xml
in both thecomplete
andinitial
folders)compose.yaml
compose.yaml
contents changed to match what comes from Spring Initializr exactlycompose.yaml
to the initial folderBuild an executable JAR
Previously the guide walked the user through building an executable jar, but that section needed to be rewritten given the reliance on Spring Boot Docker compose. While rewriting that section, I added additional content on using buildpacks and native images. Whereas the previous guide only focused on building an executable jar, this update proposes walking the user through 4 ways to build the application.
This PR should address issues #41 #39 #37