Skip to content

Commit

Permalink
Add Dockerfile & local running instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
benefacto committed Jul 3, 2024
1 parent bf3b1e2 commit 5cd5a38
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:lts
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install
COPY . .
RUN yarn build
CMD ["yarn", "mm-snap", "serve"]
67 changes: 64 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,70 @@ type State = {
This snap exposes an `onRpcRequest` handler, which supports the following JSON-RPC methods:

- `setState` - Set the state to the provided parameters. This assumes the new state is an object using the above structure. The state is always stored encrypted.
- `getState` - Get the state from the snap. This returns the current state if one is set, or a default state otherwise. The method always retrieves state from the encrypted store.
- `clearState` - Reset the state to the default state. The method always retrieves state from the encrypted store.
- `getState` - Get the state from the snap. This returns the current state if one is set, or a default state otherwise. The state from the encrypted store is always retrieved.
- `clearState` - Reset the state to the default state. The state from the encrypted store is always cleared.

Interacting with encrypted storage requires MetaMask to be unlocked.
Encrypted storage requires MetaMask to be unlocked.

For more information, you can refer to [the end-to-end tests](./src/index.test.ts).

## Running the Snap Locally

### Prerequisites

Make sure you have `nvm` (Node Version Manager) installed. If not, you can install it by following the instructions [here](https://github.com/nvm-sh/nvm#installing-and-updating).

### Without Docker

1. **Install the correct Node.js version:**

```sh
nvm install
nvm use
```

This will use the Node.js version specified in the `.nvmrc` file.

2. **Install the dependencies:**

```sh
yarn install
```

3. **Build the project:**

```sh
yarn build
```

4. **Start the Snap:**

```sh
yarn start
```

5. **Run tests:**

```sh
yarn test
```

### With Docker

You can also build and run this snap locally using Docker.

1. **Build the Docker image**

Navigate to the directory containing the `Dockerfile` and run:

```sh
docker build -t zazen-snap .
```

2. **Run the Docker container**

```sh
docker run -d -p 8081:8081 zazen-snap
```

This command will run the container and map port `8081` of the container to port `8081` of your host machine, allowing you to access the snap locally for testing.

0 comments on commit 5cd5a38

Please sign in to comment.