Skip to content

Commit 760c39c

Browse files
authored
Anni/pages build image update (#16752)
* Changing header to 'Build image' from 'Language support and tools' for easier search. * Pages build system documentation format and content update. Major change includes adding instructions for overriding versions. * Fix spelling mistake. * Add 'any version' note to both tables. * Minor tweaks * updates to the build system content * content + route fix * added redirect route * Renaming section to Build Image * small capitalization fix * link fixes
1 parent ba8a33b commit 760c39c

File tree

8 files changed

+108
-72
lines changed

8 files changed

+108
-72
lines changed

public/_redirects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@
779779
/pages/framework-guides/deploy-a-vue-application/ /pages/framework-guides/deploy-a-vue-site 301
780780
/pages/how-to/deploy-a-zola-site/ /pages/framework-guides/deploy-a-zola-site/ 301
781781
/pages/how-to/elderjs/ /pages/framework-guides/deploy-an-elderjs-site/ 301
782+
/pages/configuration/language-support-and-tools/ /pages/configuration/build-image/ 301
782783
/pages/platform/github-integration/ /pages/configuration/git-integration/ 301
783784
/pages/platform/direct-uploads/ /pages/get-started/direct-upload/ 301
784785
/pages/platform/direct-upload/ /pages/get-started/direct-upload/ 301

src/content/docs/pages/configuration/build-caching.mdx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
22
pcx_content_type: concept
33
title: Build caching
4-
54
---
65

76
Improve Pages build times by turning on build caching to restore dependencies and build output between builds. The first build to occur after enabling build caching on your Pages project will save to cache. Every subsequent build will restore from cache unless configured otherwise.
87

98
## Requirements
109

11-
Build caching requires the [V2 build system](/pages/configuration/language-support-and-tools/) or later. To update from V1, refer to the [V2 build system migration instructions](/pages/configuration/language-support-and-tools/#v2-build-system).
10+
Build caching requires the [V2 build system](/pages/configuration/build-image/#v2-build-system) or later. To update from V1, refer to the [V2 build system migration instructions](/pages/configuration/build-image/#v1-to-v2-migration).
1211

1312
## Configuration
1413

@@ -39,10 +38,10 @@ When enabled, the build cache will automatically detect and cache data from each
3938

4039
Package manager caches are automatically saved to the build cache to speed up dependency installation. Pages will cache the global cache directories of the following package managers:
4140

42-
* [yarn 1](https://yarnpkg.com/)
43-
* [npm](https://www.npmjs.com/)
44-
* [pnpm](https://pnpm.io/)
45-
* [bun](https://bun.sh/)
41+
- [yarn 1](https://yarnpkg.com/)
42+
- [npm](https://www.npmjs.com/)
43+
- [pnpm](https://pnpm.io/)
44+
- [bun](https://bun.sh/)
4645

4746
### Frameworks
4847

@@ -61,8 +60,8 @@ Caching the build output from frameworks can speed up subsequent build times. Th
6160

6261
During this beta period, the following limits are imposed:
6362

64-
* **Retention**: Cache is purged seven days after its last read date. Unread cache artifacts are purged seven days after creation.
65-
* **Storage**: Every project is allocated 10 GB. If the project cache exceeds this limit, the project will automatically start deleting artifacts that were read least recently.
63+
- **Retention**: Cache is purged seven days after its last read date. Unread cache artifacts are purged seven days after creation.
64+
- **Storage**: Every project is allocated 10 GB. If the project cache exceeds this limit, the project will automatically start deleting artifacts that were read least recently.
6665

6766
## Feedback
6867

src/content/docs/pages/configuration/build-configuration.mdx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
pcx_content_type: concept
33
title: Build configuration
44
rss: https://github.com/cloudflare/cloudflare-docs/commits/production/content/pages/_partials/_build-configuration.atom
5-
65
---
76

8-
import { Details, PagesBuildPresetsTable } from "~/components"
7+
import { Details, PagesBuildPresetsTable } from "~/components";
98

109
You may tell Cloudflare Pages how your site needs to be built as well as where its output files will be located.
1110

@@ -15,16 +14,14 @@ You should provide a build command to tell Cloudflare Pages how to build your ap
1514

1615
Build directories indicates where your project's build command outputs the built version of your Cloudflare Pages site. Often, this defaults to the industry-standard `public`, but you may find that you need to customize it.
1716

18-
1917
<Details header="Understanding your build configuration">
2018

21-
The build command is provided by your framework. For example, the Gatsby framework uses `gatsby build` as its build command. When you are working without a framework, leave the **Build command** field blank. Pages determines whether a build has succeeded or failed by reading the exit code returned from the user supplied build command. Any non-zero return code will cause a build to be marked as failed. An exit code of 0 will cause the Pages build to be marked as successful and assets will be uploaded regardless of if error logs are written to standard error.
19+
The build command is provided by your framework. For example, the Gatsby framework uses `gatsby build` as its build command. When you are working without a framework, leave the **Build command** field blank. Pages determines whether a build has succeeded or failed by reading the exit code returned from the user supplied build command. Any non-zero return code will cause a build to be marked as failed. An exit code of 0 will cause the Pages build to be marked as successful and assets will be uploaded regardless of if error logs are written to standard error.
2220

2321
The build directory is generated from the build command. Each framework has its own naming convention, for example, the build output directory is named `/public` for many frameworks.
2422

2523
The root directory is where your site’s content lives. If not specified, Cloudflare assumes that your linked git repository is the root directory. The root directory needs to be specified in cases like monorepos, where there may be multiple projects in one repository.
2624

27-
2825
</Details>
2926

3027
## Framework presets
@@ -52,7 +49,3 @@ The following system environment variables are injected by default (but can be o
5249
| `CF_PAGES_COMMIT_SHA` | `<sha1-hash-of-current-commit>` | Passing current commit ID to error reporting, for example, Sentry |
5350
| `CF_PAGES_BRANCH` | `<branch-name-of-current-deployment>` | Customizing build based on branch, for example, disabling debug logging on `production` |
5451
| `CF_PAGES_URL` | `<url-of-current-deployment>` | Allowing build tools to know the URL the page will be deployed at |
55-
56-
## Language support and tools
57-
58-
Moved to [Language support and tools](/pages/configuration/language-support-and-tools/).
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
pcx_content_type: concept
3+
title: Build image
4+
rss: https://github.com/cloudflare/cloudflare-docs/commits/production/content/pages/_partials/_platform-language-support-and-tools.atom
5+
---
6+
7+
import {
8+
PagesBuildEnvironment,
9+
PagesBuildEnvironmentLanguages,
10+
PagesBuildEnvironmentTools,
11+
} from "~/components";
12+
13+
Cloudflare Pages' build environment has broad support for a variety of languages, such as Ruby, Node.js, Python, PHP, and Go.
14+
15+
If you need to use a [specific version](/pages/configuration/build-image/#overriding-default-versions) of a language, (for example, Node.js or Ruby) you can specify it by providing an associated environment variable in your build configuration, or setting the relevant file in your source code.
16+
17+
## Supported languages and tools
18+
19+
In the following tables, review the preinstalled versions for languages and tools included in the Cloudflare Pages' build image, and the environment variables and/or files available for [overriding the preinstalled version](/pages/configuration/build-image/#overriding-default-versions):
20+
21+
### Languages and runtime
22+
23+
<PagesBuildEnvironmentLanguages />
24+
25+
:::note[Any version]
26+
Under Supported versions, "Any version" refers to support for all versions of the language or tool including versions newer than the Default version.
27+
:::
28+
29+
### Tools
30+
31+
<PagesBuildEnvironmentTools />
32+
33+
:::note[Any version]
34+
Under Supported versions, "Any version" refers to support for all versions of the language or tool including versions newer than the Default version.
35+
:::
36+
37+
### Frameworks
38+
39+
To use a specific version of a framework, specify it in the project's package manager configuration file.
40+
For example, if you use Gatsby, your `package.json` should include the following:
41+
42+
```
43+
"dependencies": {
44+
"gatsby": "^5.13.7",
45+
}
46+
```
47+
48+
When your build starts, if not already [cached](/pages/configuration/build-caching/), version 5.13.7 of Gatsby will be installed using `npm install`.
49+
50+
## Overriding default versions
51+
52+
To override default versions of languages and tools in the build system, you can either set the desired version through environment variables or by adding files to your project.
53+
54+
To set the version using **environment variables**, you can:
55+
56+
1. Find the environment variable name for the language or tool in [this table](/pages/configuration/build-image/#supported-languages-and-tools).
57+
2. Add the environment variable on the dashboard by going to **Settings** > **Environmnet variables** in your Pages project, or [add the environment variable via Wrangler](/workers/configuration/environment-variables/#add-environment-variables-via-wrangler).
58+
59+
Or, to set the version by **adding a file** to your project, you can:
60+
61+
1. Find the environment variable name for the language or tool in [this table](/pages/configuration/build-image/#supported-languages-and-tools).
62+
2. Add the specified file name to the root directory of your project, and add the desired version number as the contents of the file.
63+
64+
For example, if you were previously relying on the default version of Node.js in the v1 build system, to migrate to v2, you must specify that you need Node.js `12.18.0` by setting a `NODE_VERSION = 12.18.0` environment variable or by adding a `.node-version` or `.nvmrc` file to your project with `12.18.0` added as the contents to the file.
65+
66+
## V2 build system
67+
68+
The [v2 build system](https://blog.cloudflare.com/moderizing-cloudflare-pages-builds-toolbox/) announced in May 2023 brings several improvements to project builds.
69+
70+
### V1 to V2 Migration
71+
72+
To migrate to this new version, configure your Pages project settings in the dashboard:
73+
74+
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
75+
2. Select **Workers & Pages** > in **Overview**, select your Pages project.
76+
3. Go to **Settings** > **Build & deployments** > **Build system version** and select the latest version.
77+
78+
If you were previously relying on the default versions of any languages or tools in the build system, your build may fail when migrating to v2. To fix this, you must specify the version you wish to use by [overriding](/pages/configuration/build-image/#overriding-default-versions) the default versions.
79+
80+
### Limitations
81+
82+
Here are some limitations with the v2 build system:
83+
84+
- Specifying Node.js versions as codenames (for example, `hydrogen` or `lts/hydrogen`).
85+
- Detecting Yarn version from `yarn.lock` file version.
86+
- Detecting pnpm version detection based `pnpm-lock.yaml` file version.
87+
- Detecting Node.js and package managers from `package.json` -> `"engines"`.
88+
- `pipenv` and `Pipfile` support.
89+
90+
## Build environment
91+
92+
Cloudflare Pages builds are run in a [gVisor](https://gvisor.dev/docs/) container.
93+
94+
<PagesBuildEnvironment />

src/content/docs/pages/configuration/language-support-and-tools.mdx

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/content/docs/pages/configuration/monorepos.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
pcx_content_type: concept
33
title: Monorepos
4-
54
---
65

76
While some apps are built from a single repository, Pages also supports apps with more complex setups. A monorepo is a repository that has multiple subdirectories each containing its own application.
@@ -39,5 +38,5 @@ While Pages does not provide specialized tooling for dependency management in mo
3938

4039
## Limitations
4140

42-
* You must be using [Build System V2](/pages/configuration/language-support-and-tools) or later in order for monorepo support to be enabled.
43-
* You can configure a maximum of 5 Pages projects per repository. If you need this limit raised, contact your Cloudflare account team or use the [Limit Increase Request Form](https://docs.google.com/forms/d/e/1FAIpQLSd_fwAVOboH9SlutMonzbhCxuuuOmiU1L_I5O2CFbXf_XXMRg/viewform).
41+
- You must be using [Build System V2](/pages/configuration/build-image/#v2-build-system/) or later in order for monorepo support to be enabled.
42+
- You can configure a maximum of 5 Pages projects per repository. If you need this limit raised, contact your Cloudflare account team or use the [Limit Increase Request Form](https://docs.google.com/forms/d/e/1FAIpQLSd_fwAVOboH9SlutMonzbhCxuuuOmiU1L_I5O2CFbXf_XXMRg/viewform).

src/content/docs/pages/framework-guides/deploy-a-jekyll-site.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ To deploy your site to Pages:
7070

7171
<PagesBuildPreset framework="jekyll" />
7272

73-
Add an [environment variable](/pages/configuration/language-support-and-tools/) that matches the Ruby version that you are using locally. Set this as `RUBY_VERSION` on both your preview and production deployments. Below, `3.1.3` is used as an example:
73+
Add an [environment variable](/pages/configuration/build-image/) that matches the Ruby version that you are using locally. Set this as `RUBY_VERSION` on both your preview and production deployments. Below, `3.1.3` is used as an example:
7474

7575
| Environment variable | Value |
7676
| -------------------- | ------- |

src/content/docs/pages/functions/wrangler-configuration.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ API_KEY = "1234567asdf"
5555

5656
### V2 build system
5757

58-
Pages Functions configuration via `wrangler.toml` requires the [V2 build system](/pages/configuration/language-support-and-tools/) or later. To update from V1, refer to the [V2 build system migration instructions](/pages/configuration/language-support-and-tools/#v2-build-system).
58+
Pages Functions configuration via `wrangler.toml` requires the [V2 build system](/pages/configuration/build-image/#v2-build-system) or later. To update from V1, refer to the [V2 build system migration instructions](/pages/configuration/build-image/#v1-to-v2-migration).
5959

6060
### Wrangler
6161

0 commit comments

Comments
 (0)