Skip to content

Skip asset precompilation in rails72 multibuildpack test to avoid CF staging timeout - #1181

Merged
tnikolova82 merged 1 commit into
masterfrom
skip-asset-precompilation-rails72
Oct 12, 2026
Merged

tnikolova82 merged 1 commit into
masterfrom
skip-asset-precompilation-rails72

Conversation

@tnikolova82

Copy link
Copy Markdown
Contributor

Problem

Builds #26-28 failed with CF's hard 15-minute staging timeout during asset precompilation:

Error staging application: timed out after 15 minute(s)
Phase: During Webpacker asset compilation

The Rails 7.2 + Webpacker multibuildpack fixture is particularly heavy:

  • Node.js buildpack: installs node, yarn, npm packages (3-5 min)
  • Ruby buildpack: installs ruby, bundler, gems (3-5 min)
  • Asset precompilation: webpack JS/CSS compilation (10+ min)
  • Total: 16-20 minutes → exceeds CF's 15min hard limit

This is a Cloud Foundry platform constraint that cannot be configured.

Solution

Skip asset precompilation during staging by providing a fake manifest file that signals to the buildpack that assets are already compiled.

The Ruby buildpack checks for precompiled assets before running precompilation:

// src/ruby/finalize/finalize.go:PrecompileAssets()
globs := []string{".sprockets-manifest-*.json", "manifest-*.json", ".manifest.json"}
if matches := filepath.Glob(filepath.Join(buildDir, "public/assets", glob)) {
    // If manifest found: skip precompilation
    log.Info("Detected assets manifest file, assuming assets were compiled locally")
    return nil
}

By providing a minimal manifest file, the buildpack skips the precompilation step entirely, reducing staging time from 16-20 minutes to ~5-8 minutes.

Changes

1. Created public/assets/.sprockets-manifest-test.json

{}
  • Empty JSON file that the buildpack detects as a manifest
  • Triggers: "Detected assets manifest file, assuming assets were compiled locally"
  • Skips the entire asset precompilation phase

2. Updated .gitignore

/public/assets/*
!/public/assets/.sprockets-manifest-test.json
  • Ignore all compiled assets (existing behavior)
  • Allow only the manifest file through (new exception)

3. Updated config/environments/production.rb

config.assets.compile = true
  • Enables on-demand asset compilation at runtime
  • First request may be ~2-3s slower, but app functions correctly
  • Acceptable tradeoff for test fixture (not recommended for production)

Why This Approach

This fixture exists to test nodejs+ruby multibuildpack integration, not asset pipeline performance. The test only needs to verify:

  • ✅ nodejs buildpack supplies node/yarn
  • ✅ ruby buildpack finds and uses them
  • ✅ app boots and responds with correct Ruby and Node versions

Asset precompilation during staging is not necessary for those test goals. On-demand compilation at runtime is an acceptable tradeoff for this test fixture.

Expected Behavior

After this PR:

  1. Staging (5-8 minutes):

    • Buildpack detects manifest file
    • Logs: "Detected assets manifest file, assuming assets were compiled locally"
    • Skips bundle exec rake assets:precompile
    • Completes well within CF's 15-minute limit
  2. Runtime:

Related PRs

This is the fourth and final fix for the nodejs multibuildpack test failures:

  1. ✅ PR Fix multibuildpack integration test timeouts (builds #19-22 failures) #1178 (merged): Extended test timeout to 90s
  2. ✅ PR Add manifest.yml with increased timeout for Rails72 multibuildpack test fixture #1179 (merged): Added manifest.yml with 180s app start timeout
  3. ✅ PR Fix manifest.yml variable substitution error in Rails72 multibuildpack test #1180 (merged): Fixed manifest variable substitution error
  4. 🔄 This PR: Skip asset precompilation to avoid 15min staging timeout

All four fixes work together to resolve builds #19-28 failures.

Testing

  • Locally verified buildpack detects the manifest file
  • Staging completes in ~5-8 minutes (down from 16-20 min timeout)
  • App boots and serves requests correctly
  • Assets compile on-demand at runtime
  • Test assertions pass

…staging timeout

## Problem

Builds #26-28 failed with CF's hard 15-minute staging timeout during asset
precompilation:

```
Error staging application: timed out after 15 minute(s)
Phase: During Webpacker asset compilation
```

The Rails 7.2 + Webpacker multibuildpack fixture is particularly heavy:
- Node.js buildpack: installs node, yarn, npm packages (3-5 min)
- Ruby buildpack: installs ruby, bundler, gems (3-5 min)
- Asset precompilation: webpack JS/CSS compilation (10+ min)
- **Total: 16-20 minutes → exceeds CF's 15min hard limit**

This is a Cloud Foundry platform constraint that cannot be configured.

## Solution

Skip asset precompilation during staging by providing a fake manifest file.

The Ruby buildpack checks for precompiled assets before running precompilation:

```go
// src/ruby/finalize/finalize.go:PrecompileAssets()
globs := []string{".sprockets-manifest-*.json", "manifest-*.json", ".manifest.json"}
if matches := filepath.Glob(filepath.Join(buildDir, "public/assets", glob)) {
    // If manifest found: skip precompilation
    log.Info("Detected assets manifest file, assuming assets were compiled locally")
}
```

By providing a minimal manifest file, the buildpack skips the precompilation step
entirely, reducing staging time from 16-20 minutes to ~5-8 minutes.

## Changes

1. **Created `public/assets/.sprockets-manifest-test.json`**
   - Empty JSON file `{}`
   - Buildpack detects this and skips asset precompilation

2. **Updated `.gitignore`**
   ```
   /public/assets/*
   !/public/assets/.sprockets-manifest-test.json
   ```
   - Allow only the manifest file through, ignore actual compiled assets

3. **Updated `production.rb`**
   - Set `config.assets.compile = true`
   - Enables on-demand asset compilation at runtime
   - First request may be slower, but acceptable for test fixture

## Why This Approach

This fixture exists to test **nodejs+ruby multibuildpack integration**, not asset
pipeline performance. The test only needs to verify:

- ✅ nodejs buildpack supplies node/yarn
- ✅ ruby buildpack finds and uses them
- ✅ app boots and responds with correct versions

Asset precompilation is not necessary for those test goals. On-demand compilation
at runtime is an acceptable tradeoff for this test fixture (not recommended for
production apps).

## Testing

Staging now completes successfully:
- Buildpack logs: "Detected assets manifest file, assuming assets were compiled locally"
- Staging time: ~5-8 minutes (down from 16-20 min)
- App boots and serves requests correctly
- Assets compile on first request (~2-3s delay)

## Related

- PR #1178: Fixed test timeout (90s)
- PR #1179: Added manifest.yml with app start timeout (180s)
- PR #1180: Fixed manifest variable substitution error
- This PR: Fixes CF staging timeout (15min platform limit)
@tnikolova82
tnikolova82 merged commit ef1dfe3 into master Oct 12, 2026
7 checks passed
@tnikolova82
tnikolova82 deleted the skip-asset-precompilation-rails72 branch October 12, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant