optimism icon indicating copy to clipboard operation
optimism copied to clipboard

docker container persistent issue

Open huahuayu opened this issue 2 years ago • 6 comments

Hi, my system disk is just 20GB, but have another 1T disk, so I want to use that disk for storage. But the docker compose file use /var dir as default.

I suggest that add an environment variable in .env file for setting a base dir for storage.

If I am right, only optimism/infra/op-replica/docker-compose/replica.yml needs to change.

huahuayu avatar Apr 29 '22 11:04 huahuayu

These two local volumes consume all the disk space in the system disk. It should be configable.

$ sudo docker volume inspect op-replica_dtl
[
    {
        "CreatedAt": "2022-05-01T00:00:03Z",
        "Driver": "local",
        "Labels": {
            "com.docker.compose.project": "op-replica",
            "com.docker.compose.version": "2.4.1",
            "com.docker.compose.volume": "dtl"
        },
        "Mountpoint": "/var/lib/docker/volumes/op-replica_dtl/_data",
        "Name": "op-replica_dtl",
        "Options": null,
        "Scope": "local"
    }
]

$ sudo docker volume inspect op-replica_geth
[
    {
        "CreatedAt": "2022-04-29T11:21:05Z",
        "Driver": "local",
        "Labels": {
            "com.docker.compose.project": "op-replica",
            "com.docker.compose.version": "2.4.1",
            "com.docker.compose.volume": "geth"
        },
        "Mountpoint": "/var/lib/docker/volumes/op-replica_geth/_data",
        "Name": "op-replica_geth",
        "Options": null,
        "Scope": "local"
    }
]

huahuayu avatar May 04 '22 08:05 huahuayu

Hi @optimisticben how do you think?

huahuayu avatar May 04 '22 09:05 huahuayu

I would rather use an overlay solution instead of adding more configuration to the setup.

Something like a new yaml file, and include this in the COMPOSE_FILE env list.

---
version: "3.4"
x-logging: &logging
  logging:
    driver: json-file
    options:
      max-size: 10m
      max-file: "3"

services:
  data-transport-layer:
    volumes:
      - <PATH ON LOCALHOST>:/db
  l2geth-replica:
    volumes:
      - <PATH ON LOCALHOST>:/geth

Using host path mapping involves localhost issues I'd rather avoid in an example deployment 😁

optimisticben avatar May 04 '22 18:05 optimisticben

Works for me. So will you merge it or not?

Here is my script to run optimism

#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail

SRC_DIR=$HOME
VERSION=@eth-optimism/[email protected]
ETH_RPC=<rpc_url>
DATA_DIR=/data/optimism

mkdir -p $DATA_DIR/dtl/db
mkdir -p $DATA_DIR/l2geth/geth
cd $SRC_DIR
if [[ -e $SRC_DIR/optimism ]]
then
    cd $SRC_DIR/optimism
    git reset --hard
    git fetch --all
    git checkout tags/$VERSION 1>/dev/null
else
    git clone https://github.com/ethereum-optimism/optimism.git
    git checkout tags/$VERSION 1>/dev/null
fi
cd $SRC_DIR/optimism/infra/op-replica/docker-compose/
cp default-mainnet.env .env
sed -i "s|WONT_WORK_UNLESS_YOU_PROVIDE_A_VALID_ETHEREUM_L1_ENDPOINT|$ETH_RPC|" .env
sed -i 's|COMPOSE_FILE=replica.yml:replica-shared.yml:replica-toml.yml|COMPOSE_FILE=replica.yml:replica-shared.yml:replica-toml.yml:replica-volume.yml|' .env
cat > replica-volume.yml <<EOF
---
version: "3.4"
x-logging: &logging
  logging:
    driver: json-file
    options:
      max-size: 10m
      max-file: "3"

services:
  data-transport-layer:
    volumes:
      - $DATA_DIR/dtl/db:/db
  l2geth-replica:
    volumes:
      - $DATA_DIR/l2geth/geth:/geth
EOF

sudo docker-compose up -d

huahuayu avatar May 05 '22 10:05 huahuayu

LGTM!

If you create a PR for the infra/op-replica/docker-compose/contrib with a README on how the script is expected to be used, we'll get the team to review.

optimisticben avatar May 05 '22 14:05 optimisticben

Can we also introduce template variables to set the memory limit on L2Geth and DTL? I would like to put some sane memory limits on the services as well via env variable.

diwu1989 avatar May 27 '22 06:05 diwu1989