Skip to content

Commit

Permalink
Update docs on live reload
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Vitale <[email protected]>
  • Loading branch information
ThomasVitale committed May 5, 2024
1 parent 70acef7 commit a28782b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
4 changes: 4 additions & 0 deletions 01-java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ Run the application on the local JVM as follows.

Now, try making some changes to the application (for example, updating the REST API) and save.
Spring Boot Developer Tools will automatically reload the application with the new classes.

If you use Visual Studio Code, the live reload functionality works without any additional configuration.

If you use IntelliJ IDEA, refer to the [official documentation](https://www.jetbrains.com/help/idea/spring-boot.html#application-update-policies) to enable support for Spring Boot DevTools in the IDE.
2 changes: 1 addition & 1 deletion 02-container-image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ You can also debug the application from your IDE. Check out the configuration in
## Live Reload

Paketo, the Cloud Native Buildpacks implementation we used above, provides support for live-reload.
You can enable it via the `BP_LIVE_RELOAD_ENABLED` environment variable, as demonstrated in `live-reload/book-service/build.gradle`.
You can enable it via the `BP_LIVE_RELOAD_ENABLED` environment variable, as demonstrated in `live-reload/book-service/build.gradle`. For more information, refer to the [official documentation](https://paketo.io/docs/howto/java/#enable-process-reloading).

Then, you would need a tool like Spring Boot Developer Tools to take care of loading into the images the changed classes every time they are updated. We'll use the live reload capabilities provided by Buildpacks when working with Tilt.
20 changes: 20 additions & 0 deletions 04-tilt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ tilt up

Now you can work with the application, save your changes, and they will be automatically loaded into the container running in Kubernetes. You can also debug it by attaching a remote debugger from your IDE to the Pod.

The Tilt setup in the `Tiltfile` is tuned to work with Visual Studio Code without any additional configuration.

If you use IntelliJ IDEA, refer to the [official documentation](https://www.jetbrains.com/help/idea/spring-boot.html#application-update-policies) to enable live reload in the IDE. You also need to update the `Tiltfile` and change the folders monitored by Tilt for the live reload functionality. For more information on how it works, refer to the Paketo [official documentation](https://paketo.io/docs/howto/java/#enable-process-reloading).

```python
custom_build(
# Name of the container image
ref = 'book-service',
# Command to build the container image
command = './gradlew bootBuildImage --imageName $EXPECTED_REF',
# Files to watch that trigger a new build
deps = [ 'build.gradle', './build/classes/java/main', './build/resources/main' ],
# Enables live reload
live_update = [
sync('./build/classes/java/main', '/workspace/BOOT-INF/classes'),
sync('./build/resources/main', '/workspace/BOOT-INF/classes')
]
)
```

## Clean-up

When you're done, delete the cluster as follows.
Expand Down
38 changes: 38 additions & 0 deletions 05-skaffold/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,44 @@ skaffold dev --port-forward

Now you can work with the application, save your changes, and they will be automatically loaded into the container running in Kubernetes. You can also debug it by attaching a remote debugger from your IDE to the Pod by starting Skaffold with `skaffold debug`.

The Skaffold setup in the `skaffold.yml` file is tuned to work with Visual Studio Code without any additional configuration.

If you use IntelliJ IDEA, refer to the [official documentation](https://www.jetbrains.com/help/idea/spring-boot.html#application-update-policies) to enable live reload in the IDE. You also need to update the `skaffold.yml` file and change the folders monitored by Skaffold for the live reload functionality. For more information on how it works, refer to the Paketo [official documentation](https://paketo.io/docs/howto/java/#enable-process-reloading).

```yaml
apiVersion: skaffold/v4beta10
kind: Config
metadata:
name: book-service
build:
artifacts:
- image: book-service
buildpacks:
# Change to docker.io/paketobuildpacks/builder-jammy-base on ARM64
builder: docker.io/dashaun/builder:base
trustBuilder: true
env:
- BP_JVM_VERSION=21
- BP_LIVE_RELOAD_ENABLED=true
dependencies:
paths:
- build.gradle
- src/main/resources
- build/classes/java/main
- build/resources/main
sync:
manual:
- src: "src/main/resources/**/*"
dest: /workspace/BOOT-INF/classes
strip: src/main/resources/
- src: "build/classes/java/main/**/*"
dest: /workspace/BOOT-INF/classes
strip: build/classes/java/main/
- src: "build/resources/main/**/*"
dest: /workspace/BOOT-INF/classes
strip: build/resources/main/
```
## Clean-up
When you're done, delete the cluster as follows.
Expand Down

0 comments on commit a28782b

Please sign in to comment.