Skip to content

Commit

Permalink
Merge pull request #752 from hyounes4560/expand-slice-layers-page
Browse files Browse the repository at this point in the history
expand slice layers page
  • Loading branch information
natalieparellano committed Jul 31, 2024
1 parent 74d65af commit 7dd7868
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<meta name="description" content="After all buildpacks have executed, the contents of the application directory will be included in the final application image as a single layer, OR as slice layers. A slice layer contains a portion…"/>
<link rel="canonical" content="https://buildpacks.io/docs/for-buildpack-authors/how-to/write-buildpacks/create-slice-layers/">
<link rel="icon" type="image/png" href="/images/favicon.png">

Expand All @@ -22,7 +22,7 @@
<meta property="og:url" content="https://buildpacks.io/docs/for-buildpack-authors/how-to/write-buildpacks/create-slice-layers/">
<meta property="og:locale" content="en_US">
<meta property="og:site_name" content="Cloud Native Buildpacks">

<meta property="og:description" content="After all buildpacks have executed, the contents of the application directory will be included in the final application image as a single layer, OR as slice layers. A slice layer contains a portion…">
<meta property="og:type" content="article">
<meta property="og:image" content="https://buildpacks.io/images/buildpacks-social-card.jpg">
<meta property="og:image:alt" content="Buildpacks project logo">
Expand Down Expand Up @@ -897,8 +897,29 @@
<h1 class="title">Create slice layers</h1>
</div>

<p>This page is a stub! The CNB project is applying to <a href="https://developers.google.com/season-of-docs/docs/timeline">Google Season of Docs</a> to receive support for improving our documentation. Please check back soon.</p>
<p>If you are familiar with this content and would like to make a contribution, please feel free to open a PR :)</p>
<p>After all buildpacks have executed, the contents of the application directory will be included in the final application image as a single layer, OR as <code>slice</code> layers. A <code>slice</code> layer contains a portion of the application directory as defined by a <code>filepath</code> glob.</p>
<p><code>Slices</code> are useful to avoid re-uploading unchanged data to the image registry. For example, if the application directory is a monolithic repository containing code for both a web frontend and sever backend, buildpacks can slice the directory into separate layers. Thus developers iterating on one part of the code base don&rsquo;t have to wait for the entire directory to re-upload at the end of the build.</p>
<h2 id="key-points">Key Points</h2>
<ul>
<li>For each <code>slice</code>, buildpacks MUST specify zero or more <code>path globs</code> such that each path is either:
<ul>
<li>Relative to the root of the app directory without traversing outside of the app directory</li>
<li>Absolute and contained within the app directory</li>
</ul>
</li>
<li><code>Path globs</code> MUST:
<ul>
<li>Follow the pattern syntax defined in the <a href="https://golang.org/pkg/path/filepath/#Match">Go standard library</a></li>
<li>Match zero or more files or directories</li>
</ul>
</li>
<li><code>Slices</code> from earlier buildpacks are processed before <code>slices</code> from later buildpacks. When a file is included in a <code>slice</code>, it is as if it no longer exists in the application directory for processing future <code>slices</code>.</li>
</ul>
<h2 id="implementation-steps">Implementation Steps</h2>
<p><code>Slices</code> are added to the <a href="https://github.com/buildpacks/spec/blob/main/buildpack.md#launchtoml-toml">launch.toml</a> file in the <code>&lt;layers&gt;/&lt;layer&gt;</code> directory as follows:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-toml" data-lang="toml"><span class="line"><span class="cl"><span class="p">[[</span><span class="nx">slices</span><span class="p">]]</span>
</span></span><span class="line"><span class="cl"><span class="nx">paths</span> <span class="p">=</span> <span class="p">[</span><span class="s2">&#34;&lt;app sub-path glob&gt;&#34;</span><span class="p">]</span>
</span></span></code></pre></div><p>A buildpack may specify sub-paths within <code>&lt;app&gt;</code> as <code>slices</code> in <code>launch.toml</code>. The lifecycle will create separate layers during the <a href="https://buildpacks.io/docs/for-buildpack-authors/concepts/lifecycle-phases/#phase-5-export">export</a> phase for each slice containing one or more files or directories. Any files in the <code>&lt;app&gt;</code> directory that are not included in buildpack-defined slices will be included in the image as a final slice layer.</p>



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ <h2><a href="https://buildpacks.io/docs/for-buildpack-authors/how-to/write-build
</div>

<h2><a href="https://buildpacks.io/docs/for-buildpack-authors/how-to/write-buildpacks/create-slice-layers/" class="">Create slice layers</a></h2>
<p class="m-1"></p>
<p class="m-1">After all buildpacks have executed, the contents of the application directory will be included in the final application image as a single layer, OR as <code>slice</code> layers. A <code>slice</code> layer contains a portion of the application directory as defined by a <code>filepath</code> glob.</p>


<div class="text-md-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<link>https://buildpacks.io/docs/for-buildpack-authors/how-to/write-buildpacks/create-slice-layers/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://buildpacks.io/docs/for-buildpack-authors/how-to/write-buildpacks/create-slice-layers/</guid>
<description></description>
<description>&lt;p&gt;After all buildpacks have executed, the contents of the application directory will be included in the final application image as a single layer, OR as &lt;code&gt;slice&lt;/code&gt; layers. A &lt;code&gt;slice&lt;/code&gt; layer contains a portion of the application directory as defined by a &lt;code&gt;filepath&lt;/code&gt; glob.&lt;/p&gt;</description>
</item>
<item>
<title>Re-use dependency layers</title>
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">

<head>
<meta name="generator" content="Hugo 0.129.0">
<meta name="generator" content="Hugo 0.130.0">



Expand Down
2 changes: 1 addition & 1 deletion index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@
<link>https://buildpacks.io/docs/for-buildpack-authors/how-to/write-buildpacks/create-slice-layers/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://buildpacks.io/docs/for-buildpack-authors/how-to/write-buildpacks/create-slice-layers/</guid>
<description></description>
<description>&lt;p&gt;After all buildpacks have executed, the contents of the application directory will be included in the final application image as a single layer, OR as &lt;code&gt;slice&lt;/code&gt; layers. A &lt;code&gt;slice&lt;/code&gt; layer contains a portion of the application directory as defined by a &lt;code&gt;filepath&lt;/code&gt; glob.&lt;/p&gt;</description>
</item>
<item>
<title>Re-use dependency layers</title>
Expand Down

0 comments on commit 7dd7868

Please sign in to comment.