Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web container #253

Merged
merged 64 commits into from
Nov 8, 2024
Merged

web container #253

merged 64 commits into from
Nov 8, 2024

Conversation

chenyan-dfinity
Copy link
Contributor

@chenyan-dfinity chenyan-dfinity commented Sep 6, 2024

Workflow:

  • Import files from github. Binary/image files are saved in the container, but not displayed in the folder
  • Deploy backend to generate JS binding, environment variable, canister_id.json and .env files needed for frontend build
  • If the folder contains package.json, a selection of non-".mo" file will enable frontend build
  • Frontend build copies everything from state.files into the container, and run npm install, npm run build
  • Deploy asset canister. Authorize a random identity and copy the identity to the container
  • Inside the container, run node upploadAsset.js <asset_canister> <dist_dir>

Known limitations:

  • Update the asset doesn't refresh the TTL. What's a good API without being abused?
  • Cannot talk to local replica inside the web container. But it seems to be a problem on the replica side...There are two workarounds: 1) copy the build artifact from container and upload in the main browser code; 2) talk to the mainnet inside container
  • Only fully supported in Chrome. Firefox may have CORS problem running npm install in jsh. Normal deployment is fine. Safari support is only in TP.

@chenyan-dfinity chenyan-dfinity marked this pull request as ready for review September 17, 2024 21:10
rvanasa
rvanasa previously approved these changes Sep 18, 2024
src/App.tsx Show resolved Hide resolved
src/App.tsx Outdated Show resolved Hide resolved
src/examples.ts Outdated
@@ -8,7 +8,7 @@ export interface ExampleProject {

const example = {
repo: "dfinity/examples",
branch: "master",
branch: "bump-agent-js",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a comment here to set this back to the master branch after it's merged.

src/examples.ts Outdated
const json = JSON.parse(packageJson);
if (json.scripts) {
Object.entries(json.scripts).forEach(([key, value]) => {
if (typeof value === "string" && value.startsWith("dfx")) {
Copy link
Contributor

@rvanasa rvanasa Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems okay for now, and perhaps we can find a more elegant way to do this in the future.

One possibility could be to create a simulated dfx command which always succeeds and prints an informational message to the console like "Skipped running command: `dfx generate my_canister`".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that's the first thing I tried. There is a PATH environment variable, but jsh doesn't seem to respect it. So we will have to call ./dfx instead of dfx. I haven't tried to pass PATH directly in spawn though.

return;
}
const userAgent = navigator.userAgent.toLowerCase();
// TODO: double check the browsers listed here indeed works
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could use one of these solutions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. It seems window.chrome is not very robust. Some versions of Edge has that, and some don't. The current solution is probably more reliable.

src/workers/file.ts Outdated Show resolved Hide resolved
chenyan-dfinity and others added 14 commits September 25, 2024 16:28
Co-authored-by: Ryan Vandersmith <[email protected]>
Co-authored-by: Ryan Vandersmith <[email protected]>
* create new canisters on demand; deploy stored wasm

* fix

* fix

* fix

* chore: Whitelist frontend canister hash from dfx version 0.24.1 (#265)

Co-authored-by: adamspofford-dfinity <[email protected]>

* fix

* fix

* fix cycle after expiration (#266)

* fix

* fix

* fix

---------

Co-authored-by: DFINITY bot <[email protected]>
Co-authored-by: adamspofford-dfinity <[email protected]>
@chenyan-dfinity chenyan-dfinity merged commit 5b6fecb into main Nov 8, 2024
5 checks passed
@chenyan-dfinity chenyan-dfinity deleted the container branch November 8, 2024 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants