Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions features/src/node/NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,32 @@ Some binaries could be taken from https://unofficial-builds.nodejs.org but ARM b

Needs access to the following URL for downloading and resolving:
* https://nodejs.org

### Corepack

:warning: Internet access is necessary for corepack to install your preferred package manager.

If you prefere to use internal sources, additional configuration is required. Add this to your `devcontainer.json`.

```json
{
"postCreateCommand": "no_proxy=.mycompany.com corepack install",
"containerEnv": {
"COREPACK_NPM_REGISTRY": "https://artifactory.mycompany.com/artifactory/api/npm/npm"
}
}
```

Notice the `no_proxy=.mycompany.com`; it is necessary because the package used by corepack does not follow the common rules for the `no_proxy` variable. See [Rob--W/proxy-from-env/issues#29](https://github.com/Rob--W/proxy-from-env/issues/29).

For **pnpm** to work with Artifactory, you have to additionally add this to the variables of your Dev Container:

```json
{
"containerEnv": {
"COREPACK_INTEGRITY_KEYS": "0"
}
}
```

The reason for this are missing singatures in the Artifactory NPM API. See [nodejs/corepack#725](https://github.com/nodejs/corepack/issues/725)
33 changes: 32 additions & 1 deletion features/src/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ A package which installs Node.js.

```json
"features": {
"ghcr.io/postfinance/devcontainer-features/node:0.2.0": {
"ghcr.io/postfinance/devcontainer-features/node:0.3.0": {
"version": "lts",
"npmVersion": "included",
"yarnVersion": "none",
"pnpmVersion": "none",
"corepackVersion": "none",
"downloadUrl": "",
"versionsUrl": "",
"globalNpmRegistry": ""
Expand All @@ -26,6 +27,7 @@ A package which installs Node.js.
| npmVersion | The version of NPM to install. | string | included | included, latest, 10.5.0, 9.9.3 |
| yarnVersion | The version of Yarn to install. | string | none | none, latest, 1.22.22, 1.21.1 |
| pnpmVersion | The version of Pnpm to install. | string | none | none, latest, 9.14.2, 9 |
| corepackVersion | The version of corepack to install. | string | none | none, latest, 0.34.0, 0.29 |
| downloadUrl | The download URL to use for Node.js binaries. | string | <empty> | https://mycompany.com/artifactory/nodejs-generic-remote/dist |
| versionsUrl | The URL to fetch the available Node.js versions from. | string | <empty> | |
| globalNpmRegistry | The global NPM registry to use. | string | <empty> | https://mycompany.com/artifactory/api/npm/npm/ |
Expand All @@ -43,3 +45,32 @@ Some binaries could be taken from https://unofficial-builds.nodejs.org but ARM b

Needs access to the following URL for downloading and resolving:
* https://nodejs.org

### Corepack

:warning: Internet access is necessary for corepack to install your preferred package manager.

If you prefere to use internal sources, additional configuration is required. Add this to your `devcontainer.json`.

```json
{
"postCreateCommand": "no_proxy=.mycompany.com corepack install",
"containerEnv": {
"COREPACK_NPM_REGISTRY": "https://artifactory.mycompany.com/artifactory/api/npm/npm"
}
}
```

Notice the `no_proxy=.mycompany.com`; it is necessary because the package used by corepack does not follow the common rules for the `no_proxy` variable. See [Rob--W/proxy-from-env/issues#29](https://github.com/Rob--W/proxy-from-env/issues/29).

For **pnpm** to work with Artifactory, you have to additionally add this to the variables of your Dev Container:

```json
{
"containerEnv": {
"COREPACK_INTEGRITY_KEYS": "0"
}
}
```

The reason for this are missing singatures in the Artifactory NPM API. See [nodejs/corepack#725](https://github.com/nodejs/corepack/issues/725)
13 changes: 12 additions & 1 deletion features/src/node/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "node",
"version": "0.2.0",
"version": "0.3.0",
"name": "Node.js",
"description": "A package which installs Node.js.",
"options": {
Expand Down Expand Up @@ -48,6 +48,17 @@
"default": "none",
"description": "The version of Pnpm to install."
},
"corepackVersion": {
"type": "string",
"proposals": [
"none",
"latest",
"0.34.0",
"0.29"
],
"default": "none",
"description": "The version of corepack to install."
},
"downloadUrl": {
"type": "string",
"default": "",
Expand Down
1 change: 1 addition & 0 deletions features/src/node/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-npmVersion="${NPMVERSION:-"included"}" \
-yarnVersion="${YARNVERSION:-"none"}" \
-pnpmVersion="${PNPMVERSION:-"none"}" \
-corepackVersion="${COREPACKVERSION:-"none"}" \
-downloadUrl="${DOWNLOADURL:-""}" \
-versionsUrl="${VERSIONSURL:-""}" \
-globalNpmRegistry="${GLOBALNPMREGISTRY:-""}"
5 changes: 5 additions & 0 deletions features/src/node/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func runMain() error {
npmVersion := flag.String("npmVersion", "included", "")
yarnVersion := flag.String("yarnVersion", "none", "")
pnpmVersion := flag.String("pnpmVersion", "none", "")
corepackVersion := flag.String("corepackVersion", "none", "")
downloadUrl := flag.String("downloadUrl", "", "")
versionsUrl := flag.String("versionsUrl", "", "")
globalNpmRegistry := flag.String("globalNpmRegistry", "", "")
Expand Down Expand Up @@ -70,6 +71,10 @@ func runMain() error {
ComponentBase: installer.NewComponentBase("Pnpm", *pnpmVersion),
PackageName: "pnpm",
},
&npmComponent{
ComponentBase: installer.NewComponentBase("corepack", *corepackVersion),
PackageName: "corepack",
},
)
return feature.Process()
}
Expand Down
11 changes: 11 additions & 0 deletions features/test/node/corepack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e

[[ -f "$(dirname "$0")/../functions.sh" ]] && source "$(dirname "$0")/../functions.sh"
[[ -f "$(dirname "$0")/functions.sh" ]] && source "$(dirname "$0")/functions.sh"

check_version "$(node -v)" "v24.4.1"
check_version "$(corepack -v)" "0.34.0"

corepack prepare yarn@4.9.2
corepack prepare pnpm@10.14.0
14 changes: 14 additions & 0 deletions features/test/node/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,19 @@
"pnpmVersion": "9.14.2"
}
}
},
"corepack": {
"build": {
"dockerfile": "Dockerfile",
"options": [
"--add-host=host.docker.internal:host-gateway"
]
},
"features": {
"./node": {
"version": "24.4.1",
"corepackVersion": "0.34.0"
}
}
}
}