Skip to content

Commit da3ef07

Browse files
authored
Merge branch 'main' into lwshang/12.0.0-2026-03-19-04-43
2 parents 5cec95b + d4e072e commit da3ef07

File tree

8 files changed

+122
-30
lines changed

8 files changed

+122
-30
lines changed

.github/workflows/release.yml

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,22 @@ jobs:
9898
runner: ubuntu-latest
9999
arch_tag: amd64
100100
cache_suffix: cache-amd64
101+
dockerfile: Dockerfile
101102
- platform: linux/arm64
102103
runner: ubuntu-22.04-arm
103104
arch_tag: arm64
104105
cache_suffix: cache-arm64
106+
dockerfile: Dockerfile
107+
- platform: linux/amd64
108+
runner: ubuntu-latest
109+
arch_tag: amd64-engine
110+
cache_suffix: cache-amd64-engine
111+
dockerfile: cloudengine.Dockerfile
112+
- platform: linux/arm64
113+
runner: ubuntu-22.04-arm
114+
arch_tag: arm64-engine
115+
cache_suffix: cache-arm64-engine
116+
dockerfile: cloudengine.Dockerfile
105117
steps:
106118
- name: "Checkout code"
107119
uses: actions/checkout@v4
@@ -138,6 +150,7 @@ jobs:
138150
uses: docker/build-push-action@v6
139151
with:
140152
push: true
153+
file: ${{ matrix.dockerfile }}
141154
platforms: ${{ matrix.platform }}
142155
tags: |
143156
ghcr.io/${{ github.repository }}:${{ matrix.arch_tag }}
@@ -148,13 +161,32 @@ jobs:
148161
BUILDKIT_INLINE_CACHE=1
149162
150163
docker-manifest:
151-
name: "Create and push multi-arch manifest"
164+
name: "Create and push multi-arch manifest (${{ matrix.variant }})"
152165
if: ${{ github.ref_type == 'tag' }}
153166
needs: docker-build
154167
runs-on: ubuntu-latest
155168
permissions:
156169
contents: read
157170
packages: write
171+
strategy:
172+
matrix:
173+
include:
174+
- variant: standard
175+
amd64_tag: amd64
176+
arm64_tag: arm64
177+
tags: |
178+
type=ref,event=branch
179+
type=ref,event=pr
180+
type=semver,pattern={{version}}
181+
type=semver,pattern={{major}}.{{minor}}
182+
type=raw,value=${{ github.sha }},enable=true
183+
type=raw,value=latest,enable=true
184+
- variant: engine
185+
amd64_tag: amd64-engine
186+
arm64_tag: arm64-engine
187+
tags: |
188+
type=semver,pattern={{version}},suffix=-engine
189+
type=raw,value=engine-beta,enable=true
158190
steps:
159191
- name: "Checkout code"
160192
uses: actions/checkout@v4
@@ -167,13 +199,7 @@ jobs:
167199
with:
168200
images: |
169201
ghcr.io/${{ github.repository }}
170-
tags: |
171-
type=ref,event=branch
172-
type=ref,event=pr
173-
type=semver,pattern={{version}}
174-
type=semver,pattern={{major}}.{{minor}}
175-
type=raw,value=${{ github.sha }},enable=true
176-
type=raw,value=latest,enable=${{ github.ref_type == 'tag' }}
202+
tags: ${{ matrix.tags }}
177203

178204
- name: "Log in to GitHub Container Registry"
179205
uses: docker/login-action@v3
@@ -187,5 +213,5 @@ jobs:
187213
with:
188214
tags: ${{ steps.meta.outputs.tags }}
189215
sources: |
190-
ghcr.io/${{ github.repository }}:amd64
191-
ghcr.io/${{ github.repository }}:arm64
216+
ghcr.io/${{ github.repository }}:${{ matrix.amd64_tag }}
217+
ghcr.io/${{ github.repository }}:${{ matrix.arm64_tag }}

Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ edition = "2024"
55
authors = ["DFINITY Stiftung <sdk@dfinity.org>"]
66
license = "Apache-2.0"
77

8+
[features]
9+
cloud-engine = []
10+
811
[dependencies]
912
anyhow = { version = "1.0.100", features = ["backtrace"] }
1013
camino = "1.2.2"
1114
clap = { version = "4.5.53", features = ["derive", "env"] }
1215
hex = "0.4.3"
1316
ic_principal = "0.1.1"
1417
notify = "8.2.0"
15-
pocket-ic = { git = "https://github.com/dfinity/ic", rev = "781ef50bd6bfbcfac6769b55361d0624247009c1" }
18+
pocket-ic = { git = "https://github.com/dfinity/ic", rev = "d17cf0bcd330e94f868cc7d19d0ac860cbe64198" }
1619
reqwest = { version = "0.12.24", default-features = false, features = ["rustls-tls", "json"] }
1720
semver = "1.0.27"
1821
serde = { version = "1.0.228", features = ["derive"] }

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rust:1.93.1-slim-trixie AS chef
1+
FROM rust:1.94.0-slim-trixie AS chef
22
RUN apt-get update && apt-get install -y jq curl
33
WORKDIR /app
44
RUN cargo install cargo-chef --version 0.1.73 --locked

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,18 @@ When `--status-dir` is provided, the launcher writes a JSON status file (`status
142142

143143
The launcher handles `SIGINT` (Ctrl+C) and `SIGTERM` for graceful shutdown. It stops the PocketIC server and waits for it to exit before terminating.
144144

145+
### Experimental features
146+
147+
If the launcher is built with `--feature cloud-engine`, you can create subnets of type `cloud-engine`. The subnet admin is set to the anonymous principal. The `:cloudengine-beta` Docker tag is an alternative to the standard image with this feature enabled.
148+
145149
## Installing
146150

147151
`icp-cli-network-launcher` is typically installed automatically by icp-cli. It can be updated to the latest version with `icp network update`.
148152

149153
Binary downloads are also available on the [releases page](https://github.com/dfinity/icp-cli-network-launcher/releases).
150154

155+
A Docker image is published under the name `ghcr.io/dfinity/icp-cli-network-launcher`. The container port 4943 should be published for gateway access, and if a status dir is needed, mount it at `/app/status`.
156+
151157
## Development
152158

153159
### Prerequisites

cloudengine.Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM rust:1.94.0-slim-trixie AS chef
2+
RUN apt-get update && apt-get install -y jq curl
3+
WORKDIR /app
4+
RUN cargo install cargo-chef --version 0.1.73 --locked
5+
FROM chef AS planner
6+
COPY . .
7+
RUN cargo chef prepare --recipe-path recipe.json
8+
FROM chef AS builder
9+
COPY --from=planner /app/recipe.json recipe.json
10+
RUN cargo chef cook --release --recipe-path recipe.json
11+
COPY . .
12+
RUN ./package.sh out -- --features=cloud-engine
13+
FROM debian:trixie-slim AS runtime
14+
RUN apt-get update && apt-get install -y ca-certificates
15+
WORKDIR /app
16+
COPY --from=builder /app/out ./
17+
STOPSIGNAL SIGINT
18+
EXPOSE 4942/tcp 4943/tcp
19+
ENTRYPOINT ["/app/icp-cli-network-launcher", "--status-dir=/app/status", \
20+
"--config-port", "4942", "--gateway-port", "4943", \
21+
"--bind", "0.0.0.0", "--pocketic-config-bind", "0.0.0.0"]
22+
CMD ["--nns", "--ii", "--subnet=application", "--subnet=cloud-engine"]

package.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,19 @@ case $(uname -m) in
1818
aarch64*) arch="arm64";;
1919
*) echo "Unsupported architecture $(uname -m)"; exit 1;;
2020
esac
21+
22+
dir=
23+
cargo_args=()
24+
while (( $# )); do
25+
case "$1" in
26+
--) shift; cargo_args=("$@"); break;;
27+
*) [[ -z "$dir" ]] && dir="$1" || die "too many arguments";;
28+
esac
29+
shift
30+
done
31+
2132
maketarball=0
22-
if [[ -z "$1" ]]; then
33+
if [[ -z "$dir" ]]; then
2334
maketarball=1
2435
fi
2536
tar=tar
@@ -44,8 +55,8 @@ else
4455
[[ "$source" != "git+"* ]] || die "package.version is not patch but pocket-ic dependency is git"
4556
fi
4657
name="icp-cli-network-launcher-${arch}-${os}-v${v}"
47-
outdir="${1-"dist/${name}"}"
48-
cargo build --release
58+
outdir="${dir:-"dist/${name}"}"
59+
cargo build --release "${cargo_args[@]}"
4960
mkdir -p "${outdir}"
5061
cp "target/release/icp-cli-network-launcher" "${outdir}/"
5162
if [[ -z "$icdate" ]]; then

src/main.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(not(feature = "cloud-engine"), allow(unused))]
2+
13
use std::{
24
collections::HashSet,
35
fs,
@@ -14,7 +16,10 @@ use ic_principal::Principal;
1416
use notify::{Event, RecursiveMode, Watcher, recommended_watcher};
1517
use pocket_ic::{
1618
PocketIcBuilder,
17-
common::rest::{AutoProgressConfig, IcpFeatures, IcpFeaturesConfig, InstanceHttpGatewayConfig},
19+
common::rest::{
20+
AutoProgressConfig, ExtendedSubnetConfigSet, IcpFeatures, IcpFeaturesConfig,
21+
InstanceHttpGatewayConfig, SubnetSpec,
22+
},
1823
};
1924
use reqwest::Client;
2025
use semver::{Version, VersionReq};
@@ -101,6 +106,8 @@ enum SubnetKind {
101106
Fiduciary,
102107
Nns,
103108
Sns,
109+
#[cfg(feature = "cloud-engine")]
110+
CloudEngine,
104111
}
105112

106113
#[tokio::main]
@@ -218,7 +225,22 @@ async fn main() -> anyhow::Result<()> {
218225
drop(watcher);
219226
// pocket-ic CLI setup ends here
220227
// initial HTTP setup
221-
let mut pic = PocketIcBuilder::new()
228+
let mut base_subnets = ExtendedSubnetConfigSet::default();
229+
#[cfg(feature = "cloud-engine")]
230+
for _ in 0..subnet
231+
.iter()
232+
.filter(|s| matches!(s, SubnetKind::CloudEngine))
233+
.count()
234+
{
235+
use pocket_ic::common::rest::CanisterCyclesCostSchedule;
236+
237+
base_subnets.cloud_engine.push(
238+
SubnetSpec::default()
239+
.with_subnet_admins(vec![Principal::anonymous()])
240+
.with_cost_schedule(CanisterCyclesCostSchedule::Free),
241+
);
242+
}
243+
let mut pic = PocketIcBuilder::new_with_config(base_subnets)
222244
.with_server_url(
223245
format!("http://127.0.0.1:{config_port}/")
224246
.parse()
@@ -256,6 +278,8 @@ async fn main() -> anyhow::Result<()> {
256278
SubnetKind::Fiduciary => pic = pic.with_fiduciary_subnet(),
257279
SubnetKind::Nns => pic = pic.with_nns_subnet(),
258280
SubnetKind::Sns => pic = pic.with_sns_subnet(),
281+
#[cfg(feature = "cloud-engine")]
282+
SubnetKind::CloudEngine => {} // handled above
259283
}
260284
}
261285
}

0 commit comments

Comments
 (0)