Skip to content

Commit 039ff56

Browse files
authored
Simplify demo instructions (#18)
Remove docker compose because it's simpler to show docker run commands.
1 parent b6f2c05 commit 039ff56

File tree

4 files changed

+34
-52
lines changed

4 files changed

+34
-52
lines changed

Diff for: Dockerfile

-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,2 @@
11
FROM elixir:1.18.1-alpine
2-
3-
RUN mix local.hex --force
4-
5-
WORKDIR /app
6-
7-
COPY mix.exs .
8-
COPY mix.lock .
9-
10-
RUN mix deps.get
11-
122
COPY . .
13-
14-
RUN mix compile
15-
16-
CMD ["elixir", "run_with_demeter.exs"]
17-
#CMD ["elixir", "run.exs"]

Diff for: README.md

+31-22
Original file line numberDiff line numberDiff line change
@@ -39,43 +39,46 @@ For a more detailed description of different ways to use this library, read the
3939

4040
## Running via Docker
4141

42-
### Using Demeter.run
42+
In order to run the application via Docker, you need to build the image first:
4343

44-
The demo application can connect to a Cardano node at [Demeter.run](https://demeter.run/) 🪄
44+
```
45+
docker build -t xander .
46+
```
4547

46-
First, create a Node on Demeter. Then, set your Node's url in the `DEMETER_URL` environment variable in the `.env` file.
48+
With the image built, you can now connect to either a local Cardano node via a UNIX socket or to a node at Demeter.run.
4749

48-
For example:
50+
#### 1. Connecting via a local UNIX socket
4951

50-
```bash
51-
DEMETER_URL=https://your-node-at.demeter.run
52-
```
52+
This assumes you have access to a fully synced Cardano node.
53+
54+
🚨 **Note:** Socket files mapped via socat/ssh tunnels **DO NOT WORK** when using containers on OS X.
5355

54-
Then, run the application using Docker Compose:
56+
Run the previously built Docker image with the `-v` argument, which mounts the path of your local socket path to
57+
the container's default socket path (`/tmp/cardano-node.socket`):
5558

56-
```bash
57-
docker compose up --build
59+
```
60+
docker run --rm \
61+
-v /your/local/node.socket:/tmp/cardano-node.socket \
62+
xander elixir run.exs
5863
```
5964

60-
#### Via local UNIX socket
65+
#### 2. Connecting to a node at Demeter.run
6166

62-
🚨 **Note:** Socket files mapped via socat/ssh tunnels **DO NOT WORK** when using containers on OS X.
67+
The demo application can connect to a Cardano node at [Demeter.run](https://demeter.run/) 🪄
6368

64-
Uncomment the `volumes` section in the `compose.yml` file to mount the local UNIX socket to the container's socket path.
69+
First, create a Node on Demeter and grab the Node's URL.
6570

66-
```yml
67-
volumes:
68-
- /path/to/node.socket:/tmp/cardano-node.socket
69-
```
71+
Then, run the Docker image with the `DEMETER_URL` environment variable set to your Node's URL:
7072

71-
Then, run the application using Docker Compose:
7273
```bash
73-
docker compose up --build
74+
docker run --rm \
75+
-e DEMETER_URL=https://your-node-at.demeter.run \
76+
xander elixir run_with_demeter.exs
7477
```
7578

7679
## Running natively with an Elixir local dev environment
7780

78-
#### Via local UNIX socket
81+
#### a) Via local UNIX socket
7982

8083
Run the following command using your own Cardano node's socket path:
8184

@@ -107,10 +110,16 @@ socat UNIX-LISTEN:/tmp/cardano_node.socket,reuseaddr,fork TCP:localhost:3002
107110
ssh -N -L 3002:localhost:3002 user@remote-server-ip
108111
```
109112

110-
#### Using Demeter.run
113+
4. Run the example script:
114+
115+
```bash
116+
CARDANO_NODE_PATH=/tmp/cardano_node.socket elixir run.exs
117+
```
118+
119+
#### b) Using Demeter.run
111120

112121
To connect to a node at Demeter.run, set `DEMETER_URL` to your Node Demeter URL.
113122

114123
```bash
115-
DEMETER_URL=https://your-node-at.demeter.run mix query_current_era
124+
DEMETER_URL=https://your-node-at.demeter.run elixir run_with_demeter.exs
116125
```

Diff for: compose.yml

-12
This file was deleted.

Diff for: run.exs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ Mix.install([
33
{:xander, path: Path.expand(".")}
44
])
55

6-
socket_path = System.get_env("CARDANO_NODE_SOCKET_PATH")
6+
socket_path = System.get_env("CARDANO_NODE_SOCKET_PATH", "/tmp/cardano-node.socket")
77

8-
if socket_path == nil do
9-
IO.puts("Error: CARDANO_NODE_SOCKET_PATH environment variable is not set")
8+
if !File.exists?(socket_path) do
9+
IO.puts("Error: socket file path #{socket_path} does not exist")
1010
System.halt(1)
1111
end
1212

0 commit comments

Comments
 (0)