Skip to content

Commit 44a0bcc

Browse files
authored
Merge pull request #1303 from dfinity/marc0olo/icp-cli-hosting
feat: migrate hosting examples to icp-cli + remove svelte-starter
2 parents 373f6b0 + 4fc0982 commit 44a0bcc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2185
-29920
lines changed

.github/CODEOWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
/rust/x509/ @dfinity/consensus
9393

9494
/svelte/svelte-motoko-starter/ @dfinity/sdk
95-
/svelte/svelte-starter/ @dfinity/sdk
9695
/svelte/sveltekit-starter/ @dfinity/sdk
9796

9897
/wasm/counter @dfinity/languages

.github/workflows/hosting-photo-storage-example.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,33 @@ jobs:
2020
- uses: actions/checkout@v1
2121
- name: Provision Darwin
2222
run: bash .github/workflows/provision-darwin.sh
23+
- name: Pre-download network launcher
24+
env:
25+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
run: bash .github/workflows/pre-download-launcher.sh
2327
- name: Hosting Photo Storage Darwin
2428
run: |
2529
pushd hosting/photo-storage
26-
# verify frontend deps install and build
2730
npm install
2831
npm run build
29-
# verify that frontend asset canister deploys
30-
dfx start --background
31-
dfx deploy
32+
icp network start -d
33+
icp deploy
3234
popd
3335
hosting-photo-storage-linux:
3436
runs-on: ubuntu-22.04
3537
steps:
3638
- uses: actions/checkout@v1
3739
- name: Provision Linux
3840
run: bash .github/workflows/provision-linux.sh
41+
- name: Pre-download network launcher
42+
env:
43+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: bash .github/workflows/pre-download-launcher.sh
3945
- name: Hosting Photo Storage Linux
4046
run: |
4147
pushd hosting/photo-storage
42-
# verify frontend deps install and build
4348
npm install
4449
npm run build
45-
# verify that frontend asset canister deploys
46-
dfx start --background
47-
dfx deploy
50+
icp network start -d
51+
icp deploy
4852
popd

.github/workflows/hosting-static-website-example.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,35 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.ref }}
1515
cancel-in-progress: true
1616
jobs:
17-
hosting-unity-static-website-darwin:
17+
hosting-static-website-darwin:
1818
runs-on: macos-15
1919
steps:
2020
- uses: actions/checkout@v1
2121
- name: Provision Darwin
2222
run: bash .github/workflows/provision-darwin.sh
23+
- name: Pre-download network launcher
24+
env:
25+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
run: bash .github/workflows/pre-download-launcher.sh
2327
- name: Hosting Static Website Darwin
2428
run: |
25-
dfx start --background
2629
pushd hosting/static-website
27-
dfx deploy
30+
icp network start -d
31+
icp deploy
2832
popd
2933
hosting-static-website-linux:
3034
runs-on: ubuntu-22.04
3135
steps:
3236
- uses: actions/checkout@v1
3337
- name: Provision Linux
3438
run: bash .github/workflows/provision-linux.sh
39+
- name: Pre-download network launcher
40+
env:
41+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: bash .github/workflows/pre-download-launcher.sh
3543
- name: Hosting Static Website Linux
3644
run: |
37-
dfx start --background
3845
pushd hosting/static-website
39-
dfx deploy
46+
icp network start -d
47+
icp deploy
4048
popd

.github/workflows/hosting-unity-webgl-example.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- master
66
pull_request:
77
paths:
8-
- motoko/unity-webgl-template/**
8+
- hosting/unity-webgl-template/**
99
- .github/workflows/provision-darwin.sh
1010
- .github/workflows/provision-linux.sh
1111
- .github/workflows/hosting-unity-webgl-example.yaml
@@ -20,21 +20,29 @@ jobs:
2020
- uses: actions/checkout@v1
2121
- name: Provision Darwin
2222
run: bash .github/workflows/provision-darwin.sh
23+
- name: Pre-download network launcher
24+
env:
25+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
run: bash .github/workflows/pre-download-launcher.sh
2327
- name: Hosting Unity Webgl Darwin
2428
run: |
25-
dfx start --background
2629
pushd hosting/unity-webgl-template
27-
dfx deploy
30+
icp network start -d
31+
icp deploy
2832
popd
2933
hosting-unity-webgl-linux:
3034
runs-on: ubuntu-22.04
3135
steps:
3236
- uses: actions/checkout@v1
3337
- name: Provision Linux
3438
run: bash .github/workflows/provision-linux.sh
39+
- name: Pre-download network launcher
40+
env:
41+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: bash .github/workflows/pre-download-launcher.sh
3543
- name: Hosting Unity Webgl Linux
3644
run: |
37-
dfx start --background
3845
pushd hosting/unity-webgl-template
39-
dfx deploy
46+
icp network start -d
47+
icp deploy
4048
popd
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# Pre-download the icp-cli network launcher to avoid GitHub API rate limits.
3+
# icp-cli v0.1.0 doesn't support ICP_CLI_GITHUB_TOKEN yet, so `icp network start`
4+
# hits the unauthenticated GitHub API rate limit (60 req/hr) when fetching the
5+
# latest launcher version. This script uses the authenticated `gh` CLI to get
6+
# the version, downloads the binary directly, and sets ICP_CLI_NETWORK_LAUNCHER_PATH
7+
# so icp-cli skips the API call entirely.
8+
#
9+
# Requires: GH_TOKEN env var (for authenticated GitHub API access via gh CLI)
10+
#
11+
# This workaround can be removed once icp-cli supports ICP_CLI_GITHUB_TOKEN.
12+
set -ex
13+
14+
VERSION=$(gh release view --repo dfinity/icp-cli-network-launcher --json tagName -q .tagName)
15+
16+
ARCH=$(uname -m)
17+
case "$ARCH" in
18+
arm64|aarch64) ARCH="arm64" ;;
19+
x86_64) ARCH="x86_64" ;;
20+
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
21+
esac
22+
23+
OS=$(uname -s)
24+
case "$OS" in
25+
Darwin) OS="darwin" ;;
26+
Linux) OS="linux" ;;
27+
*) echo "Unsupported OS: $OS"; exit 1 ;;
28+
esac
29+
30+
TARBALL="icp-cli-network-launcher-${ARCH}-${OS}-${VERSION}"
31+
URL="https://github.com/dfinity/icp-cli-network-launcher/releases/download/${VERSION}/${TARBALL}.tar.gz"
32+
33+
LAUNCHER_DIR="$HOME/.icp-cli-launcher"
34+
mkdir -p "$LAUNCHER_DIR"
35+
curl -sL "$URL" | tar xz -C "$LAUNCHER_DIR"
36+
37+
LAUNCHER_PATH="${LAUNCHER_DIR}/${TARBALL}/icp-cli-network-launcher"
38+
chmod +x "$LAUNCHER_PATH"
39+
40+
echo "ICP_CLI_NETWORK_LAUNCHER_PATH=${LAUNCHER_PATH}" >> "$GITHUB_ENV"
41+
echo "Network launcher ${VERSION} downloaded to ${LAUNCHER_PATH}"

.github/workflows/provision-darwin.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ curl --location --output node.pkg "https://nodejs.org/dist/v$version/node-v$vers
1616
sudo installer -pkg node.pkg -store -target /
1717
rm node.pkg
1818

19+
# Install icp-cli
20+
npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm
21+
22+
# Install ic-mops (for Motoko projects)
23+
npm install -g ic-mops
24+
1925
# Install DFINITY SDK.
2026
curl --location --output install-dfx.sh "https://raw.githubusercontent.com/dfinity/sdk/master/public/install-dfxvm.sh"
2127
DFX_VERSION=${DFX_VERSION:=0.30.2} DFXVM_INIT_YES=true bash install-dfx.sh

.github/workflows/provision-linux.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ sudo bash nodesource_setup.sh
1111
sudo apt-get install --yes nodejs
1212
rm nodesource_setup.sh
1313

14+
# Install icp-cli
15+
npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm
16+
17+
# Install ic-mops (for Motoko projects)
18+
npm install -g ic-mops
19+
1420
# Install DFINITY SDK.
1521
wget --output-document install-dfx.sh "https://raw.githubusercontent.com/dfinity/sdk/master/public/install-dfxvm.sh"
1622
DFX_VERSION=${DFX_VERSION:=0.30.2} DFXVM_INIT_YES=true bash install-dfx.sh

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.dfx/
2+
**/.icp/cache/
23
build/
34
node_modules/
5+
package-lock.json
46
dist/
57
.DS_Store
68
_MACOSX

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
path = archive/c/qr/QR-Code-generator
33
url = https://github.com/nayuki/QR-Code-generator
44
branch = fd6917601d0a77b6b6df81599118212d8cdb9a27
5-
[submodule "svelte/svelte-starter/internet-identity"]
6-
path = svelte/svelte-starter/internet-identity
7-
url = https://github.com/dfinity/internet-identity.git
85
[submodule "svelte/svelte-motoko-starter/internet-identity"]
96
path = svelte/svelte-motoko-starter/internet-identity
107
url = https://github.com/dfinity/internet-identity.git
Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,50 @@
1-
---
2-
keywords: [html5, html, godot, hosting, host a website, beginner]
3-
---
4-
51
# Godot HTML5 sample
62

73
[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/hosting/godot-html5-template)
84

95
## Overview
10-
The example shows how to deploy a Godot HTML5 build on the IC in an asset canister. The Godot HTML5 build is deployed as frontend, no backend is needed in this sample.
116

12-
This example project can be cloned, installed, and deployed locally, for learning and testing purposes. The instructions are based on running the example on either macOS or Linux, but when using WSL2 on Windows, the instructions will be the same.
7+
The example shows how to deploy a Godot HTML5 build on ICP in an asset canister. The Godot HTML5 build is deployed as frontend, no backend is needed in this sample.
138

14-
## Prerequisites
9+
## Project structure
1510

16-
This example requires an installation of:
11+
The `/frontend` folder contains the pre-built Godot HTML5 export. The frontend is deployed as an asset canister.
1712

18-
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/).
13+
## Prerequisites
1914

20-
- [x] Download and install [git](https://git-scm.com/downloads).
15+
- [x] Install [icp-cli](https://cli.icp.build): `npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm`
2116

2217
## Install
2318

24-
Clone the example dapp project:
19+
Clone the example project:
2520

2621
```bash
2722
git clone https://github.com/dfinity/examples
2823
cd examples/hosting/godot-html5-template
2924
```
3025

3126
## Deployment
32-
The local replica is started by running this command:
27+
28+
Start the local network:
3329

3430
```bash
35-
dfx start --background
31+
icp network start -d
3632
```
3733

38-
When the local replica is up and running, run this command to deploy the canisters:
34+
Deploy the canisters:
3935

4036
```bash
41-
dfx deploy
37+
icp deploy
38+
```
39+
40+
The URL for the frontend depends on the canister ID. When deployed, the URL will look like this:
41+
42+
```
43+
http://{canister_id}.localhost:8000
4244
```
4345

44-
If you get error code 500 after deploying to the IC mainnet, try to use `raw` keyword in the URL like this: `https://<canister-id>.raw.ic0.app`.
46+
Stop the local network when done:
4547

46-
## License
47-
This project is licensed under the Apache 2.0 license, see `LICENSE.md` for details. See `CONTRIBUTE.md` for details about how to contribute to this project.
48+
```bash
49+
icp network stop
50+
```

0 commit comments

Comments
 (0)