Running Internet Identity locally now that I'm supposed to use Docker

I used to understand how to run Internet Identity locally and I had it working with my projects, but I just pulled the latest source and now it seems that I’m supposed to run it in docker instead of just deploying a canister. I downloaded the Docker mac app, started it, then ran the command from the internet_identity github page:

II_FETCH_ROOT_KEY=1 dfx build; II_DUMMY_CAPTCHA=1 II_DUMMY_AUTH=1 ./scripts/docker-build

Note that I had to run dfx canister create internet_identity first or the dfx build command would not succeed and, presumably, the following command wouldn’t either.

I then browse to the following URL, which I expect to show the II login page (the cid is from internet_identity/.dfx/local/canister_ids.json and 0.0.0.0:8000 is what dfx start printed out)

http://0.0.0.0:8000/?canisterId=rrkah-fqaaa-aaaaa-aaaaq-cai

I receive the following error on that page:

Replica Error (3): "IC0304: Attempt to execute a message on canister rrkah-fqaaa-aaaaa-aaaaq-cai which contains no Wasm module"

This all made sense before Docker was involved, since I just did the below dfx deploy command as instructed on the github page (which has now been changed to the above docker script) and the internet_identity canister worked just like any other canister running locally:

II_FETCH_ROOT_KEY=1 dfx deploy --no-wallet --argument '(null)'

But now I guess the canister is maybe running somewhere other than my dfx start instance? I’m not sure why it can’t be found at the cid specified in .dfx/canister_ids.json like any of my other canisters. Maybe I just don’t understand how I’m supposed to interact with containers running inside Docker? Or is Docker just used for building the wasm and I’m somehow supposed to get it to run in dfx with another command?

The last thing the docker script prints out is COPY --from=build /internet_identity.wasm which now exists at the root of the internet_identity project. Am I supposed to do something more to get the wasm to run in my local dfx instance? I found this forum post from last year, but it’s not very helpful.

Further, the using-dev-build demo at internet-identity/demos/using-dev-build at main · dfinity/internet-identity · GitHub makes no mention of Docker and seems to want me to deploy internet_identity the old way, which works. Kind of. Instead of navigating to 0.0.0.0:8000/?canisterId=rrkah-fqaaa-aaaaa-aaaaq-cai as is printed out after deploy (which gives me an ERR_SSL_PROTOCOL_ERROR in the console and loads a blank page) or to localhost:8000/?canisterId=rrkah-fqaaa-aaaaa-aaaaq-cai (which loads a page asking me to provide a canister ID or specify a did file, as though I’m trying to load the autogenerated candid frontend, even though the cid in the url is the one from canister_ids.json for internet_identity, not __Candid_UI), I am able to load the Internet Identity login page by navigating to http://rrkah-fqaaa-aaaaa-aaaaq-cai.localhost:8000/

Sorry for the wall of text, but I’d like to take advantage of the new Docker stuff and want to be running Internet Identity as recommended, but could use some help understand how it’s supposed to work. How am I supposed to get the built wasm file, or the downloaded pre-built wasm modules from the github page to run locally?

2 Likes

Hi @mymikemiller

We use Docker to build Internet Identity, not to run it. But you don’t even have to build II as we provide prebuilt binaries. Have a look at our example here: internet-identity/demos/using-dev-build at main · dfinity/internet-identity · GitHub
This shows the minimal setup to run Internet Identity locally.

Best regards
Frederik

PS: II_FETCH_ROOT_KEY=1 dfx deploy --no-wallet --argument '(null)' still works. It might just not result in the same WASM hash. We use docker for reproducibility.

2 Likes

Ahh, I see now that you can point your canister to the built wasm using the “build” step in dfx.json. I wasn’t sure how to get a wasm into a local canister, but I guess that’s how you do it. From https://github.com/dfinity/internet-identity/blob/main/demos/using-dev-build/dfx.json:

  "canisters": {
    "internet_identity": {
      "__0": "The development build of Internet Identity. For more information, see https://github.com/dfinity/internet-identity#build-features-and-flavors",

      "type": "custom",
      "candid": "internet_identity.did",
      "wasm": "internet_identity.wasm",

      "__1": "There is no standard way to pull remote canisters, so instead we have a dummy build script that",
      "__2": "simply downloads the Internet Identity canister. See also: https://github.com/dfinity/sdk/issues/2085",
      "build": "curl -sSL https://github.com/dfinity/internet-identity/releases/latest/download/internet_identity_dev.wasm -o internet_identity.wasm"
    },
   ...
}
1 Like

Just in case somebody finds this via google: setting up Internet Identity locally is now even simpler, see the example here.

1 Like