cloudflare / cloudflare/workerd
🐛 Bug Report Debian Build? — Runtime APIs For pages workers bindings and kv. How is it hosted for you?
- Dominant language
- C++
- Stars
- 8.7k
- Forks
- 739
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 174
Description
Hi sorry to bother but you'll make your money back :)
Im trying to setup a test environment locally to run my cloudflare pages instantly for lining.
Im wondering if anyone has done this and has the code to go from a API request to a working `.capnp` config.
https://developers.cloudflare.com/api/operations/pages-project-get-project
-->
https://github.com/cloudflare/workerd/blob/42d45ba4cd41ed714b737a605a1022cc8d24cdde/src/workerd/io/cdp.capnp
```
npm install dotenv
cat > .env << EOF
CLOUDFLARE_TOKEN=
CF_ACCOUNT=
CF_PAGE=
nano buildConfig.js
node buildCOnfig.js
```
My starting script looks like the following but I'm definitely not generating the config correctly.
If anyone knows this will I need help configuring worked to host a pages repository app locally for development? Ideally, some tips on where to find the code for d1 hosting as well would be nice.
```
```
### Sample pages output
response.json
```json
{
"id": "334b8fad-*****-****-be4a-3d7a9c9eaa14",
"name": "chat",
"subdomain": "chat.pages.dev",
"domains": [
"chat.pages.dev"
],
"source": {
"type": "gitlab",
"config": {
"owner": "group",
"repo_name": "repo",
"production_branch": "main",
"pr_comments_enabled": true,
"deployments_enabled": true,
"production_deployments_enabled": true,
"preview_deployment_setting": "all",
"preview_branch_includes": [
"*"
],
"preview_branch_excludes": []
}
},
"build_config": {
"build_command": "",
"destination_dir": "chat/public",
"root_dir": "chat",
"web_analytics_tag": null,
"web_analytics_token": null
},
"deployment_configs": {
"preview": {
"env_vars": null,
"fail_open": true,
"always_use_latest_compatibility_date": false,
"compatibility_date": "2023-03-30",
"compatibility_flags": [],
"build_image_major_version": 1,
"usage_model": "bundled"
},
"production": {
"env_vars": null,
"fail_open": true,
"always_use_latest_compatibility_date": false,
"compatibility_date": "2023-03-30",
"compatibility_flags": [],
"build_image_major_version": 1,
"usage_model": "bundled"
}
},
"latest_deployment": {
"id": "e6f6c7ed-ffff-4344-9166-deeac5aadce8",
"short_id": "e6f6c7ed",
"project_id": "334b8fad-ffff-4929-be4a-3d7a9c9eaa14",
"project_name": "chat",
"environment": "production",
"url": "https://e6f6c7ed.chat.pages.dev",
"created_on": "2023-03-30T01:04:22.15252Z",
"modified_on": "2023-03-30T01:04:29.200892Z",
"latest_stage": {
"name": "build",
"started_on": "2023-03-30T01:04:28.210221Z",
"ended_on": "2023-03-30T01:04:29.200892Z",
"status": "failure"
},
"deployment_trigger": {
"type": "ad_hoc",
"metadata": {
"branch": "main",
"commit_hash": "c4a10c22222dea8a82bb5d2a76137fb07c6536e4",
"commit_message": "Commiting broken steps for later\n",
"commit_dirty": false
}
},
"stages": [
{
"name": "queued",
"started_on": "2023-03-30T01:04:22.749022Z",
"ended_on": "2023-03-30T01:04:22.651665Z",
"status": "success"
},
{
"name": "initialize",
"started_on": "2023-03-30T01:04:22.651665Z",
"ended_on": "2023-03-30T01:04:25.009217Z",
"status": "success"
},
{
"name": "clone_repo",
"started_on": "2023-03-30T01:04:25.009217Z",
"ended_on": "2023-03-30T01:04:28.210221Z",
"status": "success"
},
{
"name": "build",
"started_on": "2023-03-30T01:04:28.210221Z",
"ended_on": "2023-03-30T01:04:29.200892Z",
"status": "failure"
},
{
"name": "deploy",
"started_on": null,
"ended_on": null,
"status": "idle"
}
],
"build_config": {
"build_command": "",
"destination_dir": "chat/public",
"root_dir": "chat",
"web_analytics_tag": null,
"web_analytics_token": null
},
"source": {
"type": "gitlab",
"config": {
"owner": "group",
"repo_name": "repo",
"production_branch": "main",
"pr_comments_enabled": false
}
},
"env_vars": {},
"compatibility_date": "2023-03-30",
"compatibility_flags": [],
"build_image_major_version": 1,
"usage_model": null,
"aliases": null,
"is_skipped": false,
"production_branch": "main"
},
"canonical_deployment": null,
"created_on": "2023-03-30T01:04:09.741079Z",
"production_branch": "main",
"production_script_name": "pages-worker--956780-production",
"preview_script_name": "pages-worker--956780-preview"
}
```
```js
require('dotenv').config();
const fs = require('fs');
const CF_TOKEN = process.env.CLOUDFLARE_TOKEN;
const CF_ACCOUNT = process.env.CF_ACCOUNT;
const CF_PAGE = process.env.CF_PAGE;
// Cloudflare API endpoint
const url = `https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT}/pages/projects/${CF_PAGE}`;
// Cloudflare API request options
const options = {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.CLOUDFLARE_TOKEN}`
}
};
// Make request to Cloudflare API
fetch(url, options)
.then(res => res.json())
.then(json => {
console.log(JSON.stringify(json.result, null, 2));
const buildConfig = json.result.build_config;
const compatibilityDate = json.result.deployment_configs.production.compatibility_date;
//https://github.com/cloudflare/workerd/blob/42d45ba4cd41ed714b737a605a1022cc8d24cdde/src/workerd/io/cdp.capnp
//docs for this ists not working todo
// Construct worker config
const config = `using Workerd = import "/workerd/workerd.capnp";
const config :Workerd.Config = (
services = [
(name = "main", worker = .mainWorker),
],
sockets = [
# Serve HTTP on port 8080.
( name = "http",
address = "*:8080",
http = (),
service = "main"
),
]
);
const mainWorker :Workerd.Worker = (
# what do I put here todo .. also how do you comment on this file?
serviceWorkerScript = embed "${buildConfig.destination_dir}/worker.js",
compatibilityDate = "${compatibilityDate}"
);
`;
// Write worker config to file
fs.writeFileSync(`${process.env.CF_PAGE}.capnp`, config);
})
.catch(err => console.error('error:' + err));
```
```sh
sudo apt install bazel-bootstrap clang libc++-dev libc++abi-dev libunwind-dev ;
git clone git@github.com:cloudflare/workerd.git ;
git branch
* (HEAD detached at v1.20230321.0)
cd workerd
wget https://github.com/bazelbuild/bazel/releases/download/6.0.0/bazel-6.0.0-linux-x86_64
chmod +x bazel-6.0.0-linux-x86_64
./bazel-6.0.0-linux-x86_64 sync --configure ;
git checkout v1.20230321.0
./bazel-6.0.0-linux-x86_64 build -c opt //src/workerd/server:workerd
sudo ./bazel-6.0.0-linux-x86_64 build -c opt //src/workerd/server:worked
./bazel-6.0.0-linux-x86_64 sync --configure ;
./bazel-6.0.0-linux-x86_64 clean --expunge ;
./bazel-6.0.0-linux-x86_64 build -c opt //src/workerd/server:workerd
```
What do yall build on doesn't work out of the box on debian.
## Bug report build failing if you have a debian script lmk tried debian 11
Build log of Debian11
```
adell@adell:~/aiia/workerd$ ./bazel-6.0.0-linux-x86_64 build -c opt //src/workerd/server:workerd
Starting local Bazel server and connecting to it...
INFO: Repository v8_python_deps instantiated at:
/home/adell/aiia/workerd/WORKSPACE:297:12: in
/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/rules_python/python/pip.bzl:53:19: in pip_install
Repository rule pip_repository defined at:
/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/rules_python/python/pip_install/pip_repository.bzl:67:33: in
ERROR: An error occurred during the fetch of repository 'v8_python_deps':
Traceback (most recent call last):
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/rules_python/python/pip_install/pip_repository.bzl", line 63, column 13, in _pip_repository_impl
fail("rules_python_external failed: %s (%s)" % (result.stdout, result.stderr))
Error in fail: rules_python_external failed: (Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/__main__.py", line 16, in
from pip._internal.main import main as _main # isort:skip # noqa
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/_internal/main.py", line 13, in
from pip._internal.cli.autocompletion import autocomplete
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/_internal/cli/autocompletion.py", line 11, in
from pip._internal.cli.main_parser import create_main_parser
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/_internal/cli/main_parser.py", line 7, in
from pip._internal.cli import cmdoptions
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/_internal/cli/cmdoptions.py", line 19, in
from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/rules_python/python/pip_install/extract_wheels/__main__.py", line 5, in
main()
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/rules_python/python/pip_install/extract_wheels/__init__.py", line 87, in main
subprocess.run(pip_args, check=True)
File "/usr/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'pip', 'wheel', '-r', '/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/v8/bazel/requirements.txt', '--require-hashes']' returned non-zero exit status 1.
)
ERROR: /home/adell/aiia/workerd/WORKSPACE:297:12: fetching pip_repository rule //external:v8_python_deps: Traceback (most recent call last):
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/rules_python/python/pip_install/pip_repository.bzl", line 63, column 13, in _pip_repository_impl
fail("rules_python_external failed: %s (%s)" % (result.stdout, result.stderr))
Error in fail: rules_python_external failed: (Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/__main__.py", line 16, in
from pip._internal.main import main as _main # isort:skip # noqa
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/_internal/main.py", line 13, in
from pip._internal.cli.autocompletion import autocomplete
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/_internal/cli/autocompletion.py", line 11, in
from pip._internal.cli.main_parser import create_main_parser
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/_internal/cli/main_parser.py", line 7, in
from pip._internal.cli import cmdoptions
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/_internal/cli/cmdoptions.py", line 19, in
from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/rules_python/python/pip_install/extract_wheels/__main__.py", line 5, in
main()
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/rules_python/python/pip_install/extract_wheels/__init__.py", line 87, in main
subprocess.run(pip_args, check=True)
File "/usr/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'pip', 'wheel', '-r', '/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/v8/bazel/requirements.txt', '--require-hashes']' returned non-zero exit status 1.
)
ERROR: /home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/workerd-v8/BUILD.bazel:1:11: @workerd-v8//:v8 depends on @v8//:v8_icu in repository @v8 which failed to fetch. no such package '@v8_python_deps//': rules_python_external failed: (Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/__main__.py", line 16, in
from pip._internal.main import main as _main # isort:skip # noqa
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/_internal/main.py", line 13, in
from pip._internal.cli.autocompletion import autocomplete
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/_internal/cli/autocompletion.py", line 11, in
from pip._internal.cli.main_parser import create_main_parser
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/_internal/cli/main_parser.py", line 7, in
from pip._internal.cli import cmdoptions
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/pypi__pip/pip/_internal/cli/cmdoptions.py", line 19, in
from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/rules_python/python/pip_install/extract_wheels/__main__.py", line 5, in
main()
File "/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/rules_python/python/pip_install/extract_wheels/__init__.py", line 87, in main
subprocess.run(pip_args, check=True)
File "/usr/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'pip', 'wheel', '-r', '/home/adell/.cache/bazel/_bazel_adell/ca1d99de772f6e2c92150cfac4814e38/external/v8/bazel/requirements.txt', '--require-hashes']' returned non-zero exit status 1.
)
ERROR: Analysis of target '//src/workerd/server:workerd' failed; build aborted:
INFO: Elapsed time: 170.759s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (175 packages loaded, 8720 targets configured)
currently loading: @v8//
Fetching repository @crates_vendor__lolhtml-0.2.0; Updating submodules 21s
```
## ps
Last thing does anyone know where the code is for key value?
Contributor guide
Assessment
This issue has not been assessed yet.