Skip to content

Commit 9e5a09a

Browse files
authored
feat: Add docker network option in project templates (#6)
1 parent 56edf6f commit 9e5a09a

12 files changed

Lines changed: 55 additions & 699 deletions

File tree

hello-world/cargo-generate.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
backend_type = { type = "string", prompt = "What's your backend weapon of choice?", choices = ["rust", "motoko"], default = "rust" }
33
# We're only supporting react at the moment, so this variable is not really used
44
frontend_type = { type = "string", prompt = "Pick a frontend framework:", choices = ["react"], default = "react" }
5+
network_type = { type = "string", prompt = "Use the default network or a dockerized one?", choices = ["Default", "Docker"], default = "Default" }
56

67
[conditional.'backend_type == "rust"']
78
ignore = [ "motoko-backend" ]

hello-world/frontend/canister.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# yaml-language-server: $schema=https://github.com/dfinity/icp-cli/raw/refs/tags/v0.1.0-beta.2/docs/schemas/canister-yaml-schema.json
1+
# yaml-language-server: $schema=https://github.com/dfinity/icp-cli/raw/refs/tags/v0.1.0-beta.3/docs/schemas/canister-yaml-schema.json
22

33
name: frontend
44

@@ -12,7 +12,8 @@ build:
1212
command: npm ci
1313

1414
# Generate the bindings from backend.did file in the backend canister
15-
# You could choose to run this once manually and check the generated code in
15+
# You could choose to run this once manually and checkin the generated code
16+
# instead of running it every single time
1617
- type: script
1718
command: npm run generate --prefix app
1819

hello-world/icp.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
# yaml-language-server: $schema=https://github.com/dfinity/icp-cli/raw/refs/tags/v0.1.0-beta.2/docs/schemas/icp-yaml-schema.json
1+
# yaml-language-server: $schema=https://github.com/dfinity/icp-cli/raw/refs/tags/v0.1.0-beta.3/docs/schemas/icp-yaml-schema.json
22

33
canisters:
44
- backend
55
- frontend
6+
7+
{% if network_type == "Docker" -%}
8+
networks:
9+
# Override the local network with a docker network
10+
- name: local
11+
mode: managed
12+
image: ghcr.io/dfinity/icp-cli-network-launcher
13+
port-mapping:
14+
- 0:4943
15+
16+
{%- endif %}

hello-world/motoko-backend/canister.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# yaml-language-server: $schema=https://github.com/dfinity/icp-cli/raw/refs/tags/v0.1.0-beta.2/docs/schemas/canister-yaml-schema.json
1+
# yaml-language-server: $schema=https://github.com/dfinity/icp-cli/raw/refs/tags/v0.1.0-beta.3/docs/schemas/canister-yaml-schema.json
22

33
name: backend
44
recipe:

hello-world/rust-backend/canister.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# yaml-language-server: $schema=https://github.com/dfinity/icp-cli/raw/refs/tags/v0.1.0-beta.2/docs/schemas/canister-yaml-schema.json
1+
# yaml-language-server: $schema=https://github.com/dfinity/icp-cli/raw/refs/tags/v0.1.0-beta.3/docs/schemas/canister-yaml-schema.json
22
#
33
name: backend
44
recipe:

motoko/cargo-generate.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[placeholders]
2+
network_type = { type = "string", prompt = "Use the default network or a dockerized one?", choices = ["Default", "Docker"], default = "Default" }
3+

motoko/icp.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# yaml-language-server: $schema=https://github.com/dfinity/icp-cli/raw/refs/tags/v0.1.0-beta.2/docs/schemas/icp-yaml-schema.json
1+
# yaml-language-server: $schema=https://github.com/dfinity/icp-cli/raw/refs/tags/v0.1.0-beta.3/docs/schemas/icp-yaml-schema.json
22

33
canisters:
44
- name: {{project-name}}
@@ -10,3 +10,13 @@ canisters:
1010
# optional
1111
candid: {{project-name}}.did
1212

13+
{% if network_type == "Docker" -%}
14+
networks:
15+
# Override the local network with a docker network
16+
- name: local
17+
mode: managed
18+
image: ghcr.io/dfinity/icp-cli-network-launcher
19+
port-mapping:
20+
- 0:4943
21+
22+
{%- endif %}

0 commit comments

Comments
 (0)