From d64cd2737a43ff3b804b6128e264f1f0510f1562 Mon Sep 17 00:00:00 2001 From: antondlr Date: Tue, 25 Jun 2024 12:59:51 +0200 Subject: [PATCH] add docker-compose (#243) Co-authored-by: Ricki Moore --- README.md | 124 ++++++--------------------------------------- docker-compose.yml | 8 +++ 2 files changed, 23 insertions(+), 109 deletions(-) create mode 100644 docker-compose.yml diff --git a/README.md b/README.md index cbc71519..585ee3f7 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..41e184e5 --- /dev/null +++ b/docker-compose.yml @@ -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