From 88411a6a26e503ca58faed6ad83b9edb00e0557a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 20 Feb 2022 15:24:03 -0500 Subject: [PATCH] Persist backing `/data/` filesystem across container runs --- piker/data/_ahab.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/piker/data/_ahab.py b/piker/data/_ahab.py index 9ec805a8..59bb4d55 100644 --- a/piker/data/_ahab.py +++ b/piker/data/_ahab.py @@ -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,