Deploy Internet Identity locally
So, you are looking to deploy Internet Identity (II) locally?
Here are my four easiest solution to do so!
To deploy II locally, we need to get its canister (Wasm module). We can either build the code ourself, using Docker and the docker-build script provided by the II team, or download an existing release.
As I really dislike doing anything Devops related myself and, also because the goal of this tutorial is to make things happen fast, the following solutions are using the pre-build/released wasm (the above second option).
The first two options are applicable for any dapps, the last two are more useful if you start a new project.
1. Automatic Installation
It is possible to set up II for a project with
dfx >= 0.12.0 using a
So, just drop the following configuration in your project and that’s already it.
dfx < v0.12.0, it’s a bit more verbose — or hacky depends the point of view — but we can also leverage the
build callback to download and install II automatically.
"build": "bash -c 'test -f internet_identity.wasm || curl -sSL https://github.com/dfinity/internet-identity/releases/latest/download/internet_identity_dev.wasm -o internet_identity.wasm; test -f internet_identity.did || curl -sSL https://raw.githubusercontent.com/dfinity/internet-identity/main/src/internet_identity/internet_identity.did -o internet_identity.did'",
As we only want to deploy II locally, it is worth to note that above config contains a
remote option that points to II on mainnet. Thanks to it, the wasm won’t be deployed when we deploy our canisters to mainnet.
You might also want to skip committing the
.wasm files — that are going to be automatically downloaded — by omitting these in your
2. Manual Installation
If you prefer to not touch any configuration of your project, it is possible to deploy II locally manually as well. e.g. that’s the strategy I personally use when I deploy Papyrs.
Anywhere on your computer, while
dfx start has been started in your project, run following command lines and that’s already it too.
git clone https://github.com/dfinity/internet-identity
dfx deploy --no-wallet --argument '(null)'
3. New dapp
If you start from scratch or looking to create a sample dapp, instead of initializing a new project with
dfx, I recommend you to use the
npm CLI (I have created). It prompts you interactively for options and setup everything for you including II.
npm init ic