|
1 | 1 | # Local CRE environment |
2 | 2 |
|
| 3 | +## Contact Us |
| 4 | +Slack: #topic-local-dev-environments |
| 5 | + |
3 | 6 | ## Table of content |
4 | 7 |
|
5 | 8 | 1. [Using the CLI](#using-the-cli) |
|
16 | 19 |
|
17 | 20 | The CLI manages CRE test environments. It is located in `core/scripts/cre/environment`. |
18 | 21 |
|
| 22 | + |
| 23 | + |
19 | 24 | ## Prerequisites (for Docker) ### |
20 | 25 | 1. **Docker installed and running** |
21 | 26 | - with usage of default Docker socket **enabled** |
22 | 27 | - with Apple Virtualization framework **enabled** |
23 | 28 | - with VirtioFS **enabled** |
24 | 29 | - with use of containerd for pulling and storing images **disabled** |
25 | | -2. **Job Distributor Docker image available** |
26 | | - - Either build it locally as described in [this section](#job-distributor-image) |
27 | | - - or download it from the PROD ECR (if you have access) and tag as `job-distributor:0.9.0` |
28 | | - |
29 | | -If you want to run an example workflow you also need to: |
30 | | - |
31 | | -1. **Download CRE CLI v0.2.0** |
32 | | - - download it either from [smartcontract/dev-platform](https://github.com/smartcontractkit/dev-platform/releases/tag/v0.2.0) |
33 | | - - or using GH CLI by running: `gh release download v0.2.0 --repo smartcontractkit/dev-platform --pattern 'cre_v0.2.0_darwin_arm64.tar.gz'` |
34 | | - - once you have the archive downloaded run: |
35 | | - ```bash |
36 | | - tar -xf cre_v0.2.0_darwin_arm64.tar.gz |
37 | | - rm cre_v0.2.0_darwin_arm64.tar.gz |
38 | | - # do not worry about potential 'No such xattr: com.apple.quarantine' error |
39 | | - xattr -d com.apple.quarantine cre_v0.2.0_darwin_arm64 |
40 | | - export "PATH=$(pwd):$PATH" |
41 | | - ``` |
42 | | - |
43 | | -> Minimum required version of the `GH CLI` is `v2.50.0` |
44 | | - |
45 | | -Optionally: |
46 | | -1. **Choose the Right Topology** |
47 | | - - For a single DON with all capabilities: `configs/single-don.toml` (default) |
48 | | - - For a full topology (workflow DON + capabilities DON + gateway DON): `configs/workflow-capabilities-don.toml` |
49 | | -2. **Download or Build Capability Binaries** |
50 | | - - Some capabilities like `cron`, `log-event-trigger`, or `read-contract` are not embedded in all Chainlink images. |
51 | | - - If your use case requires them, you can either: |
52 | | - - Download binaries from [smartcontractkit/capabilities](https://github.com/smartcontractkit/capabilities/releases/tag/v1.0.2-alpha) release page or |
53 | | - - Use GH CLI to download them, e.g. `gh release download v1.0.2-alpha --repo smartcontractkit/capabilities --pattern 'amd64_cron' && mv amd64_cron cron` |
54 | | - Make sure they are built for `linux/amd64`! |
55 | | - |
56 | | - Once that is done reference them in your TOML like: |
57 | | - ```toml |
58 | | - [extra_capabilities] |
59 | | - cron_capability_binary_path = "./cron" # remember to adjust binary name and path |
60 | | - # log even trigger and read-contract binaries go here |
61 | | - # they are all commented out by default |
62 | | - ``` |
63 | | - Do make sure that the path to the binary is either relative to the `environment` folder or absolute. Then the binary will be copied to the Docker image. |
64 | | - - If the capability is already baked into your CL image (check the Dockerfile), comment out the TOML path line to skip copying. (they will be commented out by default) |
65 | | -3. **Decide whether to build or reuse Chainlink Docker Image** |
66 | | - - By default, the config builds the Docker image from your local branch. To use an existing image change to: |
67 | | - ```toml |
68 | | - [nodesets.node_specs.node] |
69 | | - image = "<your-Docker-image>:<your-tag>" |
70 | | - ``` |
71 | | - - Make these changes for **all** nodes in the nodeset in the TOML config. |
72 | | - - If you decide to reuse a Chainlink Docker Image using the `--with-plugins-docker-image` flag, please notice that this will not copy any capability binaries to the image. |
73 | | - You will need to make sure that all the capabilities you need are baked in the image you are using. |
| 30 | +2. **AWS SSO access to SDLC** |
| 31 | + - REQUIRED: `sdlc` profile |
| 32 | +3. **gh cli** |
| 33 | + - To pull the `cre` cli. Minimum version `v.2.50.0` |
74 | 34 |
|
75 | | -4. **Decide whether to use Docker or k8s** |
76 | | - - Read [Docker vs Kubernetes in guidelines.md](../../../../system-tests/tests/smoke/cre/guidelines.md) to learn how to switch between Docker and Kubernetes |
77 | | -5. **Start Observability Stack (Docker-only)** |
78 | | - ```bash |
79 | | - # to start Loki, Grafana and Prometheus run: |
80 | | - ctf obs up |
81 | 35 |
|
82 | | - # to start Blockscout block explorer run: |
83 | | - ctf bs u |
84 | | - ``` |
85 | | - - To download the `ctf` binary follow the steps described [here](https://smartcontractkit.github.io/chainlink-testing-framework/framework/getting_started.html) |
86 | | - |
87 | | -Optional environment variables used by the CLI: |
88 | | -- `CTF_CONFIGS`: TOML config paths. Defaults to [./configs/single-don.toml](./configs/single-don.toml) |
89 | | -- `PRIVATE_KEY`: Plaintext private key that will be used for all deployments (needs to be funded). Defaults to `ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80` |
90 | | -- `TESTCONTAINERS_RYUK_DISABLED`: Set to "true" to disable cleanup. Defaults to `false` |
| 36 | + [See more for configuring AWS in CLL](https://smartcontract-it.atlassian.net/wiki/spaces/INFRA/pages/1045495923/Configure+the+AWS+CLI) |
91 | 37 |
|
92 | | -When starting the environment in AWS-managed Kubernetes make sure to source `.env` environment from the `crib/deployments/cre` folder specific for AWS. Remember, that it must include ingress domain settings. |
93 | 38 |
|
94 | | ---- |
| 39 | +# QUICKSTART |
| 40 | +``` |
| 41 | +go run main.go env setup --config single-don.toml |
| 42 | +go run main.go env start |
| 43 | +``` |
95 | 44 |
|
| 45 | +The script will ensure all pre-requisites are configured and installed for the `single-don.toml` profile. |
| 46 | +If you are missing requirements, you may need to fix the errors and re-run. |
| 47 | +Use `#topic-local-dev-environments` for help |
96 | 48 | ## Start Environment |
97 | 49 | ```bash |
98 | 50 | # while in core/scripts/cre/environment |
@@ -154,6 +106,60 @@ Remember that the CRE CLI version needs to match your CPU architecture and opera |
154 | 106 |
|
155 | 107 | --- |
156 | 108 |
|
| 109 | + |
| 110 | +### Advanced Usage: |
| 111 | +1. **Choose the Right Topology** |
| 112 | + - For a single DON with all capabilities: `configs/single-don.toml` (default) |
| 113 | + - For a full topology (workflow DON + capabilities DON + gateway DON): `configs/workflow-capabilities-don.toml` |
| 114 | +2. **Download or Build Capability Binaries** |
| 115 | + - Some capabilities like `cron`, `log-event-trigger`, or `read-contract` are not embedded in all Chainlink images. |
| 116 | + - If your use case requires them, you can either: |
| 117 | + - Download binaries from [smartcontractkit/capabilities](https://github.com/smartcontractkit/capabilities/releases/tag/v1.0.2-alpha) release page or |
| 118 | + - Use GH CLI to download them, e.g. `gh release download v1.0.2-alpha --repo smartcontractkit/capabilities --pattern 'amd64_cron' && mv amd64_cron cron` |
| 119 | + Make sure they are built for `linux/amd64`! |
| 120 | + |
| 121 | + Once that is done reference them in your TOML like: |
| 122 | + ```toml |
| 123 | + [extra_capabilities] |
| 124 | + cron_capability_binary_path = "./cron" # remember to adjust binary name and path |
| 125 | + # log even trigger and read-contract binaries go here |
| 126 | + # they are all commented out by default |
| 127 | + ``` |
| 128 | + Do make sure that the path to the binary is either relative to the `environment` folder or absolute. Then the binary will be copied to the Docker image. |
| 129 | + - If the capability is already baked into your CL image (check the Dockerfile), comment out the TOML path line to skip copying. (they will be commented out by default) |
| 130 | +3. **Decide whether to build or reuse Chainlink Docker Image** |
| 131 | + - By default, the config builds the Docker image from your local branch. To use an existing image change to: |
| 132 | + ```toml |
| 133 | + [nodesets.node_specs.node] |
| 134 | + image = "<your-Docker-image>:<your-tag>" |
| 135 | + ``` |
| 136 | + - Make these changes for **all** nodes in the nodeset in the TOML config. |
| 137 | + - If you decide to reuse a Chainlink Docker Image using the `--with-plugins-docker-image` flag, please notice that this will not copy any capability binaries to the image. |
| 138 | + You will need to make sure that all the capabilities you need are baked in the image you are using. |
| 139 | + |
| 140 | +4. **Decide whether to use Docker or k8s** |
| 141 | + - Read [Docker vs Kubernetes in guidelines.md](../../../../system-tests/tests/smoke/cre/guidelines.md) to learn how to switch between Docker and Kubernetes |
| 142 | +5. **Start Observability Stack (Docker-only)** |
| 143 | + ```bash |
| 144 | + # to start Loki, Grafana and Prometheus run: |
| 145 | + ctf obs up |
| 146 | + |
| 147 | + # to start Blockscout block explorer run: |
| 148 | + ctf bs u |
| 149 | + ``` |
| 150 | + - To download the `ctf` binary follow the steps described [here](https://smartcontractkit.github.io/chainlink-testing-framework/framework/getting_started.html) |
| 151 | + |
| 152 | +Optional environment variables used by the CLI: |
| 153 | +- `CTF_CONFIGS`: TOML config paths. Defaults to [./configs/single-don.toml](./configs/single-don.toml) |
| 154 | +- `PRIVATE_KEY`: Plaintext private key that will be used for all deployments (needs to be funded). Defaults to `ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80` |
| 155 | +- `TESTCONTAINERS_RYUK_DISABLED`: Set to "true" to disable cleanup. Defaults to `false` |
| 156 | + |
| 157 | +When starting the environment in AWS-managed Kubernetes make sure to source `.env` environment from the `crib/deployments/cre` folder specific for AWS. Remember, that it must include ingress domain settings. |
| 158 | + |
| 159 | +--- |
| 160 | + |
| 161 | + |
| 162 | + |
157 | 163 | ## DX Tracing |
158 | 164 |
|
159 | 165 | To track environment usage and quality metrics (success/failure rate, startup time) local CRE environment is integrated with DX. If you have `gh cli` configured and authenticated on your local machine it will be used to automatically setup DX integration in the background. If you don't, tracing data will be stored locally in `~/.dx/` and uploaded once either `gh cli` is available or valid `~/.dx/config.json` file appears. |
@@ -228,6 +234,16 @@ You might see multiple attempts to trigger and verify that workflow, when runnin |
228 | 234 | ### Docker fails to download public images |
229 | 235 | Make sure you are logged in to Docker. Run: `docker login` |
230 | 236 |
|
| 237 | +``` |
| 238 | +Error: failed to setup test environment: failed to create blockchains: failed to deploy blockchain: create container: Error response from daemon: Head "https://ghcr.io/v2/foundry-rs/foundry/manifests/stable": denied: denied |
| 239 | +``` |
| 240 | +your ghcr token is stale. do |
| 241 | +``` |
| 242 | +docker logout ghcr.io |
| 243 | +docker pull ghcr.io/foundry-rs/foundry |
| 244 | +``` |
| 245 | +and try starting the environment |
| 246 | + |
231 | 247 | ### GH CLI is not installed |
232 | 248 | Either download from [cli.github.com](https://cli.github.com) or install with Homebrew with: |
233 | 249 | ```bash |
|
0 commit comments