Skip to content

Commit

Permalink
Merge pull request #633 from jose-fully-ported/patch-1
Browse files Browse the repository at this point in the history
docs: update current buildpack version
  • Loading branch information
AidanDelaney committed Dec 7, 2023
1 parent 405ac82 commit 7ac49d6
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 205 deletions.
37 changes: 9 additions & 28 deletions docs/buildpack-author-guide/create-buildpack/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,82 +12,63 @@
<link>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/setup-local-environment/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/setup-local-environment/</guid>
<description>First, we&amp;rsquo;ll create a sample Ruby app that you can use when developing your buildpack:
mkdir node-js-sample-app Create a file in the current directory called node-js-sample-app/app.js with the following contents:
const http = require(&amp;#39;http&amp;#39;); const hostname = &amp;#39;0.0.0.0&amp;#39;; const port = 8080; const server = http.createServer((req, res) =&amp;gt; { res.statusCode = 200; res.setHeader(&amp;#39;Content-Type&amp;#39;, &amp;#39;text/plain&amp;#39;); res.end(&amp;#39;Hello World!&amp;#39;); }); // For demo purposes we do not actually start the server. This // allows us pretend to start the server and check if the output // message is correct.</description>
<description>First, we&amp;rsquo;ll create a sample Ruby app that you can use when developing your buildpack:&#xA;mkdir node-js-sample-app Create a file in the current directory called node-js-sample-app/app.js with the following contents:&#xA;const http = require(&amp;#39;http&amp;#39;); const hostname = &amp;#39;0.0.0.0&amp;#39;; const port = 8080; const server = http.createServer((req, res) =&amp;gt; { res.statusCode = 200; res.setHeader(&amp;#39;Content-Type&amp;#39;, &amp;#39;text/plain&amp;#39;); res.end(&amp;#39;Hello World!&amp;#39;); }); // For demo purposes we do not actually start the server. This // allows us pretend to start the server and check if the output // message is correct.</description>
</item>
<item>
<title>Building blocks of a Cloud Native Buildpack</title>
<link>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/building-blocks-cnb/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/building-blocks-cnb/</guid>
<description>Now we will set up the buildpack scaffolding.
Let&amp;rsquo;s create the directory where your buildpack will live:
Using the Pack CLI The buildpack new &amp;lt;id&amp;gt; command will create a directory named for the buildpack ID.
Example:
pack buildpack new examples/node-js \ --api 0.8 \ --path node-js-buildpack \ --version 0.0.1 \ --stacks io.buildpacks.samples.stacks.jammy This command will create node-js-buildpack directory which contains buildpack.toml, bin/build, bin/detect files.
Additional Parameters -a, --api Buildpack API compatibility of the generated buildpack -h, --help Help for &amp;rsquo;new&#39; --path the location on the filesystem to generate the artifacts --stacks Stacks (deprecated) the buildpack will work with -V, --version the version of the buildpack in buildpack.</description>
<description>Now we will set up the buildpack scaffolding.&#xA;Let&amp;rsquo;s create the directory where your buildpack will live:&#xA;Using the Pack CLI The buildpack new &amp;lt;id&amp;gt; command will create a directory named for the buildpack ID.&#xA;Example:&#xA;pack buildpack new examples/node-js \ --api 0.8 \ --path node-js-buildpack \ --version 0.0.1 \ --stacks io.buildpacks.samples.stacks.jammy This command will create node-js-buildpack directory which contains buildpack.toml, bin/build, bin/detect files.&#xA;Additional Parameters -a, --api Buildpack API compatibility of the generated buildpack -h, --help Help for &amp;rsquo;new&#39; --path the location on the filesystem to generate the artifacts --stacks Stacks (deprecated) the buildpack will work with -V, --version the version of the buildpack in buildpack.</description>
</item>
<item>
<title>Detecting your application</title>
<link>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/detection/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/detection/</guid>
<description>Next, you will want to actually detect that the app you are building is a node-js app. In order to do this, you will need to check for a package.json.
Replace exit 1 in the detect script with the following check:
if [[ ! -f package.json ]]; then exit 100 fi Your node-js-buildpack/bin/detect script should look like this:
#!/usr/bin/env bash set -eo pipefail if [[ ! -f package.json ]]; then exit 100 fi Next, rebuild your app with the updated buildpack:</description>
<description>Next, you will want to actually detect that the app you are building is a node-js app. In order to do this, you will need to check for a package.json.&#xA;Replace exit 1 in the detect script with the following check:&#xA;if [[ ! -f package.json ]]; then exit 100 fi Your node-js-buildpack/bin/detect script should look like this:&#xA;#!/usr/bin/env bash set -eo pipefail if [[ ! -f package.json ]]; then exit 100 fi Next, rebuild your app with the updated buildpack:</description>
</item>
<item>
<title>Building your application</title>
<link>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/build-app/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/build-app/</guid>
<description>Now we&amp;rsquo;ll change the build step you created to install application dependencies. This will require updates to the build script such that it performs the following steps:
Create a layer for the NodeJS runtime Download the NodeJS runtime and installs it to the layer By doing this, you&amp;rsquo;ll learn how to create arbitrary layers with your buildpack, and how to read the contents of the app in order to perform actions like downloading dependencies.</description>
<description>Now we&amp;rsquo;ll change the build step you created to install application dependencies. This will require updates to the build script such that it performs the following steps:&#xA;Create a layer for the NodeJS runtime Download the NodeJS runtime and installs it to the layer By doing this, you&amp;rsquo;ll learn how to create arbitrary layers with your buildpack, and how to read the contents of the app in order to perform actions like downloading dependencies.</description>
</item>
<item>
<title>Make your application runnable</title>
<link>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/make-app-runnable/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/make-app-runnable/</guid>
<description>To make your app runnable, a default start command must be set. You&amp;rsquo;ll need to add the following to the end of your build script:
# ... # Set default start command cat &amp;gt; &amp;#34;${layersdir}/launch.toml&amp;#34; &amp;lt;&amp;lt; EOL [[processes]] type = &amp;#34;web&amp;#34; command = &amp;#34;node app.js&amp;#34; default = true EOL # ... Your full node-js-buildpack/bin/build script should now look like the following:
#!/usr/bin/env bash set -eo pipefail echo &amp;#34;---&amp;gt; NodeJS Buildpack&amp;#34; # 1.</description>
<description>To make your app runnable, a default start command must be set. You&amp;rsquo;ll need to add the following to the end of your build script:&#xA;# ... # Set default start command cat &amp;gt; &amp;#34;${layersdir}/launch.toml&amp;#34; &amp;lt;&amp;lt; EOL [[processes]] type = &amp;#34;web&amp;#34; command = &amp;#34;node app.js&amp;#34; default = true EOL # ... Your full node-js-buildpack/bin/build script should now look like the following:&#xA;#!/usr/bin/env bash set -eo pipefail echo &amp;#34;---&amp;gt; NodeJS Buildpack&amp;#34; # 1.</description>
</item>
<item>
<title>Specify multiple process types</title>
<link>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/specify-multiple-process-types/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/specify-multiple-process-types/</guid>
<description>One of the benefits of buildpacks is that they are multi-process - an image can have multiple entrypoints for each operational mode. Let&amp;rsquo;s see how this works. We will extend our app to have an entrypoint that allows a debugger to attach to it.
To enable running the debug process, we&amp;rsquo;ll need to have our buildpack define a &amp;ldquo;process type&amp;rdquo; for the worker. Modify the section where processes are defined to:</description>
<description>One of the benefits of buildpacks is that they are multi-process - an image can have multiple entrypoints for each operational mode. Let&amp;rsquo;s see how this works. We will extend our app to have an entrypoint that allows a debugger to attach to it.&#xA;To enable running the debug process, we&amp;rsquo;ll need to have our buildpack define a &amp;ldquo;process type&amp;rdquo; for the worker. Modify the section where processes are defined to:</description>
</item>
<item>
<title>Improving performance with caching</title>
<link>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/caching/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/caching/</guid>
<description>We can improve performance by caching the runtime between builds, only re-downloading when necessary. To begin, let&amp;rsquo;s cache the runtime layer.
Cache the runtime layer To do this, replace the following lines in the build script:
# 4. MAKE node-js AVAILABLE DURING LAUNCH echo -e &amp;#39;[types]\nlaunch = true&amp;#39; &amp;gt; &amp;#34;${layersdir}/node-js.toml&amp;#34; with the following:
# 4. MAKE node-js AVAILABLE DURING LAUNCH and CACHE it echo -e &amp;#39;[types]\ncache = true\nlaunch = true&amp;#39; &amp;gt; &amp;#34;${layersdir}/node-js.</description>
<description>We can improve performance by caching the runtime between builds, only re-downloading when necessary. To begin, let&amp;rsquo;s cache the runtime layer.&#xA;Cache the runtime layer To do this, replace the following lines in the build script:&#xA;# 4. MAKE node-js AVAILABLE DURING LAUNCH echo -e &amp;#39;[types]\nlaunch = true&amp;#39; &amp;gt; &amp;#34;${layersdir}/node-js.toml&amp;#34; with the following:&#xA;# 4. MAKE node-js AVAILABLE DURING LAUNCH and CACHE it echo -e &amp;#39;[types]\ncache = true\nlaunch = true&amp;#39; &amp;gt; &amp;#34;${layersdir}/node-js.</description>
</item>
<item>
<title>Making your buildpack configurable</title>
<link>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/make-buildpack-configurable/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/make-buildpack-configurable/</guid>
<description>It&amp;rsquo;s likely that not all NodeJS apps will want to use the same version of NodeJS. Let&amp;rsquo;s make the NodeJS version configurable.
Select NodeJS version We&amp;rsquo;ll allow buildpack users to define the desired NodeJS version via a .node-js-version file in their app. We&amp;rsquo;ll first update the detect script to check for this file. We will then record the dependency we can provide (NodeJS), as well as the specific dependency the application will require, in the Build Plan, a document the lifecycle uses to determine if the buildpack will provide everything the application needs.</description>
<description>It&amp;rsquo;s likely that not all NodeJS apps will want to use the same version of NodeJS. Let&amp;rsquo;s make the NodeJS version configurable.&#xA;Select NodeJS version We&amp;rsquo;ll allow buildpack users to define the desired NodeJS version via a .node-js-version file in their app. We&amp;rsquo;ll first update the detect script to check for this file. We will then record the dependency we can provide (NodeJS), as well as the specific dependency the application will require, in the Build Plan, a document the lifecycle uses to determine if the buildpack will provide everything the application needs.</description>
</item>
<item>
<title>Adding Bill-of-Materials</title>
<link>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/adding-bill-of-materials/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/adding-bill-of-materials/</guid>
<description>One of the benefits of buildpacks is they can also populate the app image with metadata from the build process, allowing you to audit the app image for information like:
The process types that are available and the commands associated with them The run-image the app image was based on The buildpacks were used to create the app image Whether the run-image can be rebased with a new version through the Rebasable label or not And more&amp;hellip;!</description>
<description>One of the benefits of buildpacks is they can also populate the app image with metadata from the build process, allowing you to audit the app image for information like:&#xA;The process types that are available and the commands associated with them The run-image the app image was based on The buildpacks were used to create the app image Whether the run-image can be rebased with a new version through the Rebasable label or not And more&amp;hellip;!</description>
</item>
</channel>
</rss>
Loading

0 comments on commit 7ac49d6

Please sign in to comment.