Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add example docker-compose #243

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 15 additions & 109 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,136 +17,42 @@ and Validator Client.
The [Lighthouse Book](https://lighthouse-book.sigmaprime.io) contains information for users and
developers. Specifically the [Lighthouse UI](https://lighthouse-book.sigmaprime.io/lighthouse-ui.html) section of the book.

## Building From Source

### Requirements

Building from source requires `Node v18` and `yarn`.

### Building From Source

The electron app can be built from source by first cloning the repository and
entering the directory:

```
$ git clone https://github.com/sigp/siren.git
$ cd siren
```

Once cloned, the electron app can be built and ran via the Makefile by:

```
$ make
```
## Running Siren

alternatively it can be built via:

```
$ yarn
```

Once completed successfully the electron app can be run via:

```
$ yarn dev
```

### Running In The Browser

#### Docker (Recommended)
### Docker (Recommended)

Docker is the recommended way to run a webserver that hosts Siren and can be
connected to via a web browser.

`docker` is required to be installed with the service running.

Recommended config for using the docker image (assuming the BN/VC API's are exposed on your localhost):

```
PORT=3000
BACKEND_URL=http://127.0.0.1:3001
VALIDATOR_URL=http://host.docker.internal:5062
BEACON_URL=http://host.docker.internal:5052
SSL_ENABLED=true
```

The docker image can be built and run with the following commands:
```
$ docker build -f Dockerfile -t siren .
```
Configuration is doen with environemnt variables, the best way to get started is by copying `.env.example` to `.env` and editing the relvant sections (typically, this would at least include `BEACON_URL`, `VALIDATOR_URL` and `API_TOKEN`)

Then to run the image:

```
$ docker run --rm -ti --name siren -p 3443:443 -v $PWD/.env:/app/.env:ro siren
```
Linux users may want to add this flag:
`--add-host=host.docker.internal:host-gateway`
`docker-compose up`
or
`docker run --rm -ti --name siren -p 3443:443 --env-file $PWD/.env sigp/siren`

This will open port 3443 and allow your browser to connect.


To start Siren, visit `https://localhost:3443` in your web browser. (ignore the certificate warning).

Advanced users can mount their own certificate with `-v $PWD/certs:/certs` (the config expects 3 files: `/certs/cert.pem` `/certs/key.pem` `/certs/key.pass`)

# Running a Local Testnet

For development, one can spin up a local lighthouse testnet. This can be used
for the UI to connect to and retrieve real-time results from a local testnet.

## Requirements

In order to run a local lighthouse network, lighthouse needs to be installed on
the system. For detailed instructions see the [Lighthouse Book](https://lighthouse-book.sigmaprime.io/).

Both `lighthouse` and `lcli` are required to be installed. This can be done by
cloning the Lighthouse repository, entering the cloned repository and running:

```bash
$ make
$ make install-lcli
```

note: you need a version of lcli that includes [these](https://github.com/sigp/lighthouse/pull/3807) changes

`ganache` is also required to be installed. This can be installed via `npm` or via the OS. If using `npm` it can be installed as:

```
$ npm install ganache --global
```

## Starting the Testnet

To start a local testnet, move into the `local-testnet` directory. Then run:

```bash
./start_local_testnet.sh genesis.json
```

This will spin up both a validator client and a beacon node. These will run in
the background and can be accessed via their local http APIs.

## Stopping the Testnet

A running local testnet can be stopped by running:
## Building From Source

```bash
./stop_local_testnet.sh
```
### Docker

## Configuring the Testnet
The docker image can be built with the following command:
`docker build -f Dockerfile -t siren .`

The default settings should be sufficient for a development network useful for
testing the UI. However various configurations can be modified by modifying the
`vars.env` file.
### Building locally

## Creating a new testnet
Building from source requires `Node v18.18` and `yarn`.

The data for a previously run testnet is stored at
`./local-testnet/testnet-data` (assuming the scripts were run inside the
`local-testnet` directory. Simply removing this directory and its
subdirectories will create a new testnet when running these commands again.
#### Build and run the backend

## Logs and Errors
#### Build and run the frontend

Logs and errors can be found in the `./local-testnet/testnet-data` directory.
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
siren:
image: sigp/siren
ports:
- "4443:443" # comment this line when using `SSL_ENABLED=false`
# - "4080:80" # uncomment this line when using `SSL_ENABLED=false`
env_file:
- .env