Persist backing `/data/` filesystem across container runs

l1_precision_fix
Tyler Goodlet 2022-02-20 15:24:03 -05:00
parent e1bbcff8e0
commit 8c558d05d6
1 changed files with 16 additions and 1 deletions

View File

@ -186,6 +186,7 @@ async def open_marketstore(
log = get_console_log('info', name=__name__)
async with open_docker() as client:
# create a mount from user's local piker config dir into container
config_dir_mnt = docker.types.Mount(
target='/etc',
@ -193,6 +194,20 @@ async def open_marketstore(
type='bind',
)
# create a user config subdir where the marketstore
# backing filesystem database can be persisted.
persistent_data_dir = os.path.join(
config._config_dir, 'data',
)
if not os.path.isdir(persistent_data_dir):
os.mkdir(persistent_data_dir)
data_dir_mnt = docker.types.Mount(
target='/data',
source=persistent_data_dir,
type='bind',
)
cntr: Container = client.containers.run(
'alpacamarkets/marketstore:latest',
# do we need this for cmds?
@ -203,7 +218,7 @@ async def open_marketstore(
'5993/tcp': 5993, # jsonrpc
'5995/tcp': 5995, # grpc
},
mounts=[config_dir_mnt],
mounts=[config_dir_mnt, data_dir_mnt],
detach=True,
stop_signal='SIGINT',
init=True,