internet-identity icon indicating copy to clipboard operation
internet-identity copied to clipboard

Dev/Production Flavours DFX

Open 7flash opened this issue 3 years ago • 8 comments

When I deploy my canisters locally with dfx deploy it's deploying II canister too.. but when I deploy to production I don't want to deploy II canister.. currently I have to either manually remove "internet_identity" field from dfx.json either deploy each canister manually "dfx deploy app_assets && dfx deploy app".. ideally I would be able to configure a specific canister to be ignored in production env

My current dfx.json

{
  "canisters": {
    "app": {
      "main": "src/app/main.mo",
      "type": "motoko"
    },
    "app_assets": {
      "dependencies": [
        "app"
      ],
      "frontend": {
        "entrypoint": "src/app_assets/src/index.html"
      },
      "source": [
        "src/app_assets/assets",
        "dist/app_assets/"
      ],
      "type": "assets"
    },
    "internet_identity": {
      "type": "custom",
      "candid": "internet_identity.did",
      "wasm": "internet_identity.wasm",
      "build": "curl -sSL https://github.com/dfinity/internet-identity/releases/download/release-2022-06-07_2/internet_identity_dev.wasm -o internet_identity.wasm"
    }
  },
  "defaults": {
    "build": {
      "args": "",
      "packtool": ""
    }
  },
  "dfx": "0.10.0",
  "networks": {
    "local": {
      "bind": "127.0.0.1:8000",
      "type": "ephemeral"
    }
  },
  "version": 1
}

7flash avatar Jun 16 '22 22:06 7flash

That makes total sense. This would be a great question for https://github.com/dfinity/sdk.

@ericswanson-dfinity thoughts on this? @bitdivine the nns-dapp also includes internet identity in its dfx.json. How do you deal with the issue?

nmattia avatar Jun 17 '22 08:06 nmattia

@7flash @nmattia I ran into the same problem. Just place a second project with Internet Identity outside your development project:

.
|- development-project  // <-- here are you developing your code
|- local-internet-identity  

The local development process looks like this:

  1. inside development-project start your local replica e.g. dfx start --background --clean
  2. cd ../local-internet-identity && dfx deploy --no-wallet --argument '(null)' && cd -
  3. note the Internet Identity Canister ID (only once required) and add it to your development-project
  4. dfx deploy
  5. optional start your frontend dev tooling or so
  6. stopping just dfx stop inside development-project

dennyweiss avatar Jun 19 '22 21:06 dennyweiss

How do you deal with the issue?

In nns-dapp we cannot deploy to mainnet, we have to make a proposal, so we don't have the issue.

That said, dfx.json should in theory list the canisters in a project, so my wish is to have a dfx.json that includes just the canisters in the project and a separate dfx.json with supporting canisters used for testing. This can be done as @dennyweiss suggested, or as follows:

  • WARNING: This is relies on a feature still in design.
  • In the main dfx.json, list the project backend and assets canisters but not II, at least not in the main section.
  • As of dfx v 0.9.2, dfx.json has fields for third party canisters that the current project depends on; add II there.
  • As of a future, unreleased dfx, it is possible to use several dfx.json with the same local testnet. This makes it possible to say git clone 3 different projects that rely on each other, run dfx start once, then deploy all three projects to the same testnet. In this case, download the II project, deploy that, then deploy your own project.

bitdivine avatar Jun 20 '22 08:06 bitdivine

The use of "remote canisters" might be a good fit here: https://github.com/dfinity/sdk/blob/master/CHANGELOG.adoc#feat-remote-canister-support

ericswanson-dfinity avatar Jun 20 '22 17:06 ericswanson-dfinity

The use of "remote canisters" might be a good fit here

Oh nice, didn't know this was live! @7flash that's definitely the correct solution

nmattia avatar Jun 21 '22 13:06 nmattia

@bitdivine I think you recently did some work to deploy Internet identity from dfx, is that correct? @ericswanson-dfinity would that be the solution here?

nmattia avatar Sep 29 '22 16:09 nmattia

@bitdivine I think you recently did some work to deploy Internet identity from dfx, is that correct? @ericswanson-dfinity would that be the solution here?

That work is pretty specific to some short-term needs for sns / nns local deployment. For other projects, I still recommend the remote canister configuration.

ericswanson-dfinity avatar Oct 11 '22 05:10 ericswanson-dfinity

Found a nice writeup from David on https://papy.rs/

Deploy Internet Identity locally

dennyweiss avatar Nov 27 '22 19:11 dennyweiss