# Deliver public assets through CDN for Spring Boot

## Summary
Cdn assets for a Spring Boot app on Ample. Verified on Spring Boot: a versioned, immutable-cached asset uploaded to a published bucket and served from the CDN URL. Build and start:
`./mvnw -q -DskipTests package` (or the Gradle wrapper) producing one application jar, then `java -jar` on the jvm-21 template (Temurin JDK 21) with server.port read from PORT.

## Representative Queries
- Deliver public assets through CDN for Spring Boot
- Where can I host Deliver public assets through CDN built with Spring Boot?
- I need a public-origin configuration, versioned asset build and observable cache behavior.

## Prerequisites
- A Spring Boot project (`./mvnw -q -DskipTests package` (or the Gradle wrapper) producing one application jar, then `java -jar` on the jvm-21 template (Temurin JDK 21) with server.port read from PORT)
- A bucket from `ample bucket create` with credentials passed as encrypted S3_* environment variables
- An Ample account token with `servers:write`, `buckets:read`

## Workflow Steps
1. **Build and start**: 
   `./mvnw -q -DskipTests package` (or the Gradle wrapper) producing one application jar, then `java -jar` on the jvm-21 template (Temurin JDK 21) with server.port read from PORT; the server must bind 0.0.0.0 on PORT.

2. **Publish a bucket for public assets**:
   Publish only the asset bucket; upload versioned keys with an immutable Cache-Control header and build URLs from its public URL.
   Command: `ample bucket publish`

3. **Verify**:
   Fetch the live URL and `/p/versioned-static-assets` on the example; on failure read the build and runtime logs.
   Command: `ample logs  --kind build`

## Success Checks
- **App responds on its public URL**
  - Kind: `http_get`
  - Path: `/`
  - Expect: `ample canary spring boot patterns`

- **Versioned-static-assets check from the example**
  - Kind: `http_get`
  - Path: `/p/versioned-static-assets`
  - Expect: `see the pattern fixture checks`

## Limitations
- Verified on the jvm-21 template at s-1vcpu-2gb; other sizes and Spring Boot major versions are not verified.
- Region, compliance attestations and request-duration limits are unknown and not claimed.
- The CDN serves published-bucket objects only; cache rules, purge and TTL control are not verified.

## Cost Estimate
- **Currency**: USD
- **Monthly Amount**: 5.0
- **Basis**: size prices from pricing.toml (loaded by the API) at build revision 1ac5595375130d45290090e82ed0f554ccd45405-dirty
- **Components**:
  - Name: app server
    - Size: s-1vcpu-1gb
    - Quantity: 1.0
    - Monthly Amount: 5.0
- **Note**: Always-on monthly price of the tested sizes; apps auto-pause when idle. Buckets are allocation-priced per quota and not included.

## Examples
- **Title**: Spring Boot pattern fixture
  - **Description**: Verified CDN assets on Spring Boot.
  - **Source Ref**: tests/deploy-canaries/spring-boot-patterns

## Evidence Summary
- **Kind**: canary_run
  - **Summary**: Spring Boot pattern fixture deployed on Ample, with necessary commands outlined.
  - **Observed At**: 2026-09-21T02:34:39Z
  - **Implementation Revision**: 1d28ae0-dirty (CLI 0.1.21)
  - **Expires At**: 2027-03-20T02:34:39Z
  - **Scope**: {"checks":["/p/versioned-static-assets"],"template":"jvm-21"}

## Next Actions
- **Browse the catalog index**
- **Search published recipes by intent, stack and constraints**
- **Prepare a side-effect-free deployment plan for an authorized project**
- **Read the existing agent authentication setup**
- **Browse Spring Boot**
- **Browse Add CDN**
- **Browse Versioned static assets**
