Skip to content

Commit

Permalink
Add ContainerApp manifest to samples
Browse files Browse the repository at this point in the history
  • Loading branch information
trisberg committed Oct 1, 2024
1 parent 142b3ac commit 88314f0
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 20 deletions.
9 changes: 5 additions & 4 deletions fragments/java-version/accelerator.axl
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
engine {
applyTo("README.md") {
UniquePath(strategy: FavorForeign)
ReplaceText(regex: {pattern: "set BP_JVM_VERSION=.*", with: 'set BP_JVM_VERSION=' + #javaVersion})
}

applyTo("pom.xml") {
ReplaceText(regex: {pattern: "<java.version>.*<", with: '<java.version>' + #javaVersion + '<'})
Expand All @@ -15,4 +11,9 @@ engine {
applyTo("build.gradle.kts") {
ReplaceText(regex: {pattern: "(?<unmodified>JavaVersion\.VERSION_)(\d+)", with: '${unmodified}' + #javaVersion})
}

applyTo(".tanzu/config/*.yml") {
OpenRewriteRecipe('org.openrewrite.yaml.ChangeValue', { oldKeyPath: "$.spec.build.nonSecretEnv[?(@.name == 'BP_JVM_VERSION')].value", value: #javaVersion})
}

}
15 changes: 15 additions & 0 deletions spring-ai-chat/.tanzu/config/spring-ai-chat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: apps.tanzu.vmware.com/v1
kind: ContainerApp
metadata:
creationTimestamp: null
name: spring-ai-chat
spec:
build:
buildpacks: {}
nonSecretEnv:
- name: BP_JVM_VERSION
value: "17"
path: ../..
ports:
- name: main
port: 8080
10 changes: 3 additions & 7 deletions spring-ai-chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,13 @@ other.
## Configuring your app environment

Change to the root directory of your generated app.
### Initialize the ContainerApp

```sh
tanzu app init
```
### Configure the JDK version
### About the ContainerApp

You need to specify the JDK version to be used for the app:
The project contains a `ContainerApp` manifest file that can be used when building and deploying the app. To review the content of this file run:

```sh
tanzu app config build non-secret-env set BP_JVM_VERSION=17
cat .tanzu/config/spring-ai-chat.yml
```

### Configure HTTP Ingress Routing
Expand Down
6 changes: 6 additions & 0 deletions spring-ai-chat/accelerator.axl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ engine {
ReplaceText({{text: "spring-ai-chat", with: #artifactId.toLowerCase()}})
}

// Update the artifact name and path as needed
applyTo(".tanzu/config/spring-ai-chat.yml") {
ReplaceText({{text: "spring-ai-chat", with: #artifactId.toLowerCase()}})
RewritePath(rewriteTo: '.tanzu/config/' + #artifactId.toLowerCase() + '.yml')
}

{
Include({'**'})
+ InvokeFragment("build-wrapper-maven")
Expand Down
6 changes: 6 additions & 0 deletions spring-ai-chat/tanzu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: config.tanzu.vmware.com/v1
configuration:
dev:
paths:
- .tanzu/config/
kind: TanzuConfig
15 changes: 15 additions & 0 deletions tanzu-java-web-app/.tanzu/config/tanzu-java-web-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: apps.tanzu.vmware.com/v1
kind: ContainerApp
metadata:
creationTimestamp: null
name: tanzu-java-web-app
spec:
build:
buildpacks: {}
nonSecretEnv:
- name: BP_JVM_VERSION
value: "17"
path: ../..
ports:
- name: main
port: 8080
12 changes: 3 additions & 9 deletions tanzu-java-web-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,12 @@ tanzu build config --containerapp-registry REGISTRY

Change to the root directory of your generated app.

### Initialize the ContainerApp
### About the ContainerApp

```sh
tanzu app init
```

### Configure the JDK version

You need to specify the JDK version to be used for the app:
The project contains a `ContainerApp` manifest file that can be used when building and deploying the app. To review the content of this file run:

```sh
tanzu app config build non-secret-env set BP_JVM_VERSION=17
cat .tanzu/config/tanzu-java-web-app.yml
```

### Configure for native build with GraalVM
Expand Down
6 changes: 6 additions & 0 deletions tanzu-java-web-app/accelerator.axl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ engine {
ReplaceText({{text: "tanzu-java-web-app", with: #artifactId.toLowerCase()}})
}

// Update the artifact name and path as needed
applyTo(".tanzu/config/tanzu-java-web-app.yml") {
ReplaceText({{text: "tanzu-java-web-app", with: #artifactId.toLowerCase()}})
RewritePath(rewriteTo: '.tanzu/config/' + #artifactId.toLowerCase() + '.yml')
}

{
Include({'**'})
// Update the java version
Expand Down
6 changes: 6 additions & 0 deletions tanzu-java-web-app/tanzu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: config.tanzu.vmware.com/v1
configuration:
dev:
paths:
- .tanzu/config/
kind: TanzuConfig

0 comments on commit 88314f0

Please sign in to comment.