## Deliver public assets through CDN for Gin

### Summary
Cdn assets for a Gin app on Ample. Verified on Gin: a versioned, immutable-cached asset uploaded to a published bucket and served from the CDN URL. Build and start: `CGO_ENABLED=0 go build -o app ./...` then `./app` on the ubuntu-24.04 template (go.sum committed for a reproducible build).

### Workload
Deliver public assets through CDN

### Framework
Gin

### Resource Requirements
- Compute
- CDN

### Infrastructure Requirements
- **Compute**: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
- **CDN**: The CDN host serves objects from published buckets. It does not front app compute and is not a cache or key-value store.

### Prerequisites
- A Gin project (`CGO_ENABLED=0 go build -o app ./...` then `./app` on the ubuntu-24.04 template (go.sum committed for a reproducible build))
- A bucket from `ample bucket create` with credentials passed as encrypted S3_* environment variables
- An Ample account token with servers:write, buckets:read

### Tested Configuration
- **Template**: ubuntu-24.04
- **Runtime**: go
- **Size**: s-1vcpu-1gb
- **Build**: `CGO_ENABLED=0 go build -o app ./...`
- **Start**: `./app`

### Workflow Steps
1. **Build and start**: `CGO_ENABLED=0 go build -o app ./...` then `./app` on the ubuntu-24.04 template (go.sum committed for a reproducible build); 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`

### Examples
- **Title**: Gin pattern fixture
  - **Description**: Verified CDN assets on Gin.
  - **Source Ref**: tests/deploy-canaries/gin-patterns

### Success Checks
- **Description**: App responds on its public URL
  - **Kind**: http_get
  - **Path**: `/`
  - **Expect**: ample canary gin patterns
- **Description**: 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 ubuntu-24.04 template at s-1vcpu-1gb; other sizes and Gin 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
- **Note**: Always-on monthly price of the tested sizes; apps auto-pause when idle. Buckets are allocation-priced per quota and not included.

### Evidence Summary
- **Kind**: canary_run
  - **Summary**: Gin pattern fixture deployed on Ample (CGO_ENABLED=0 go build -o app ./... then ./app on the ubuntu-24.04 template (go.sum committed for a reproducible build)); for this guide: a versioned, immutable-cached asset uploaded to a published bucket and served from the CDN URL.
  - **Observed At**: 2026-09-21T01:15:54Z
  - **Implementation Revision**: 50dbac567d2c5cc8e55e6c748a646be0025d9cfb-dirty (CLI 0.1.21)
  - **Expires At**: 2027-03-20T01:15:54Z

### Formats
- [HTML Link](/content/guides/gin/cdn-assets/index.html)
- [Markdown Link](/content/guides/gin/cdn-assets.md)
- [JSON Link](https://api.ample.computer/v1/catalog/recipes/page%3Aguides%3Agin%3Acdn-assets)
