code.vegaprotocol.io/vega@v0.79.0/script/postgres-docker.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # It is important that snapshotscopy{to|from} path is accessible at the same location in
     4  # the container and outside of it. If you're using a custom vega home, you must call this script
     5  # with VEGA_HOME set to your custom vega home when starting the database.
     6  
     7  if [ -n "$VEGA_HOME" ]; then
     8          VEGA_STATE=${VEGA_HOME}/state
     9  else
    10          if [[ "$OSTYPE" == "linux-gnu"* ]]; then
    11                  VEGA_STATE=~/.local/state/vega
    12          elif [[ "$OSTYPE" == "darwin"* ]]; then
    13                  VEGA_STATE="${HOME}/Library/Application Support/vega"
    14          else
    15                   echo "$OSTYPE" not supported
    16          fi
    17  fi
    18  
    19  SNAPSHOTS_COPY_TO_PATH=${VEGA_STATE}/data-node/networkhistory/snapshotscopyto
    20  SNAPSHOTS_COPY_FROM_PATH=${VEGA_STATE}/data-node/networkhistory/snapshotscopyfrom
    21  
    22  mkdir -p "$SNAPSHOTS_COPY_TO_PATH"
    23  chmod 777 "$SNAPSHOTS_COPY_TO_PATH"
    24  
    25  mkdir -p "$SNAPSHOTS_COPY_FROM_PATH"
    26  chmod 777 "$SNAPSHOTS_COPY_FROM_PATH"
    27  
    28  docker run --rm \
    29             -e POSTGRES_USER=vega \
    30             -e POSTGRES_PASSWORD=vega \
    31             -e POSTGRES_DB=vega \
    32             -p 5432:5432 \
    33             -v "$SNAPSHOTS_COPY_TO_PATH":"$SNAPSHOTS_COPY_TO_PATH":z \
    34             -v "$SNAPSHOTS_COPY_FROM_PATH":"$SNAPSHOTS_COPY_FROM_PATH":z \
    35             timescale/timescaledb:2.8.0-pg14