From b255a897337a744d1e889d0f6fe0ef3aadebdb98 Mon Sep 17 00:00:00 2001 From: Danyal Prout Date: Wed, 3 Jan 2024 20:23:33 -0600 Subject: [PATCH] Create an overridable volume for the geth data directory --- .env | 1 + .gitignore | 2 +- README.md | 16 ++++++---------- docker-compose.yml | 2 ++ 4 files changed, 10 insertions(+), 11 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..66f77df --- /dev/null +++ b/.env @@ -0,0 +1 @@ +GETH_HOST_DATA_DIR=./geth-data \ No newline at end of file diff --git a/.gitignore b/.gitignore index e4ab8e7..6019289 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /.idea/ -/geth-data/ +/geth-data/ \ No newline at end of file diff --git a/README.md b/README.md index 04bb864..30d0fdf 100644 --- a/README.md +++ b/README.md @@ -68,17 +68,13 @@ curl -d '{"id":0,"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["late Note: Some L1 nodes (e.g. Erigon) do not support fetching storage proofs. You can work around this by specifying `--l1.trustrpc` when starting op-node (add it in `op-node-entrypoint` and rebuild the docker image with `docker compose build`.) Do not do this unless you fully trust the L1 node provider. -5. Map a local data directory for `op-geth` by adding a volume mapping to the `docker-compose.yaml`: - -```yaml -services: - geth: # this is Optimism's geth client - ... - volumes: - - $HOME/data/base:/data -``` -This is where your node data will be stored. This is for example where you would extract your [snapshot](#snapshots) to. +#### Persisting Data + +By default, the data directory is stored in `${PROJECT_ROOT}/geth-data`. You can override this by modifying the value of +`GETH_HOST_DATA_DIR` variable in the [`.env`](./.env) file. + +To load a [snapshot](#snapshots) you can extract the snapshot into the `$GETH_HOST_DATA_DIR` folder. #### Running in single container with `supervisord` diff --git a/docker-compose.yml b/docker-compose.yml index d8b05c9..d4f118e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,6 +10,8 @@ services: - 30303:30303/udp # P2P UDP (currently unused) - 7301:6060 # metrics command: [ "bash", "./geth-entrypoint" ] + volumes: + - ${GETH_HOST_DATA_DIR}:/data env_file: # select your network here: # - .env.goerli