Skip to content

[build] Create CDN assets#169707

Merged
jbudz merged 9 commits intoelastic:mainfrom
jbudz:build-cdn-assets
Nov 6, 2023
Merged

[build] Create CDN assets#169707
jbudz merged 9 commits intoelastic:mainfrom
jbudz:build-cdn-assets

Conversation

@jbudz
Copy link
Contributor

@jbudz jbudz commented Oct 24, 2023

Closes #169427

Adds a new build step createCdnAssets that will create an archive kibana-<version>-cdn-assets.tar.gz with static assets organized using the request structure of the kibana client.

  • By default CDN assets are created
  • Adding the flag node scripts/build --skip-cdn-assets will skip creation
  • ci:build-cdn-assets can be used to create and upload the archive for testing

Testing: see #169408. Builds are available in the artifacts tab on the Build Distribution step.

  1. Extract builds
  2.  python3 -m http.server -b localhost -d kibana-8.12.0-SNAPSHOT-cdn-assets 8000
    
  3.  echo 'server.cdn.url: http://localhost:8000' >> kibana-8.12.0-SNAPSHOT/config/kibana.yml
    
  4. kibana-8.12.0-SNAPSHOT/bin/kibana
    

@jbudz jbudz added Team:Operations Kibana-Operations Team release_note:skip Skip the PR/issue when compiling release notes ci:build-cdn-assets Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// labels Oct 24, 2023
@jbudz

This comment was marked as duplicate.

@jbudz jbudz marked this pull request as ready for review October 24, 2023 19:09
@jbudz jbudz requested a review from a team as a code owner October 24, 2023 19:09
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

@jbudz jbudz requested a review from jloleysens October 24, 2023 19:09
Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds promising, but I think I found a few things we may want to fix.

Comment on lines +75 to +78
// Shared dependencies
await copyAll(
resolve(buildSource, 'node_modules/@kbn/ui-shared-deps-npm/shared_built_assets'),
resolve(bundles, 'kbn-ui-shared-deps-npm')
Copy link
Contributor

@pgayvallet pgayvallet Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also need to copy the assets for kbn-monaco (unless the library won't load its assets from the CDN?)

registerRouteForBundle(router, {
publicPath: `${serverBasePath}/${buildNum}/bundles/kbn-monaco/`,
routePath: `/${buildNum}/bundles/kbn-monaco/`,
bundlesPath: KbnMonaco.bundleDir,
fileHashCache,
isDist,
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the source references, I added them to the build step too. I pushed ac91ae3

Comment on lines +43 to +47
try {
const assetsSource = resolve(pluginRoot, 'assets');
const assetsDest = resolve(plugin, manifest.plugin.id, 'assets');
await access(assetsSource);
await copyAll(assetsSource, assetsDest);
Copy link
Contributor

@pgayvallet pgayvallet Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I read the path correctly, then I think this is wrong.

The plugins static assets aren't accessed/exposed as other bundles via /assets/{buildNum}/bundles/plugin/{id}/assets/{asset_path}, but via /plugins/{id}/assets/{asset_path}

E.g

previewImagePath: '/plugins/home/assets/sample_data_resources/flights/dashboard.webp',

For this file: src/plugins/home/public/assets/sample_data_resources/flights/dashboard.webp

EDIT: I finally found where we're doing it:

for (const [pluginName, pluginInfo] of uiPluginInternalInfo) {
deps.http.registerStaticDir(
`/plugins/${pluginName}/assets/{path*}`,
pluginInfo.publicAssetsDir
);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed 06a3ded

Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paths seems all correct to me, and I can't think of assets we may have forgotten to include there.

@kibana-ci
Copy link

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@Ikuni17 Ikuni17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jbudz jbudz merged commit e3c05d6 into elastic:main Nov 6, 2023
@kibanamachine kibanamachine added v8.12.0 backport:skip This PR does not require backporting labels Nov 6, 2023
jbudz added a commit that referenced this pull request Nov 7, 2023
When testing docker contexts we skip all build steps related to Kibana
artifacts. CDN assets rely on the Kibana base folder and should be
skipped too.

Fixes
https://buildkite.com/elastic/kibana-artifacts-snapshot/builds/3445
Build
https://buildkite.com/elastic/kibana-artifacts-snapshot/builds/3451
Bug introduced in #169707
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting ci:build-all-platforms ci:build-cdn-assets release_note:skip Skip the PR/issue when compiling release notes Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// Team:Operations Kibana-Operations Team v8.12.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deploy Kibana static assets into a CDN

6 participants