Persist backing `/data/` filesystem across container runs

incr_update_backup
Tyler Goodlet 2022-02-20 15:24:03 -05:00
parent 807685d27e
commit a465a11782
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__) log = get_console_log('info', name=__name__)
async with open_docker() as client: async with open_docker() as client:
# create a mount from user's local piker config dir into container # create a mount from user's local piker config dir into container
config_dir_mnt = docker.types.Mount( config_dir_mnt = docker.types.Mount(
target='/etc', target='/etc',
@ -193,6 +194,20 @@ async def open_marketstore(
type='bind', 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( cntr: Container = client.containers.run(
'alpacamarkets/marketstore:latest', 'alpacamarkets/marketstore:latest',
# do we need this for cmds? # do we need this for cmds?
@ -203,7 +218,7 @@ async def open_marketstore(
'5993/tcp': 5993, # jsonrpc '5993/tcp': 5993, # jsonrpc
'5995/tcp': 5995, # grpc '5995/tcp': 5995, # grpc
}, },
mounts=[config_dir_mnt], mounts=[config_dir_mnt, data_dir_mnt],
detach=True, detach=True,
stop_signal='SIGINT', stop_signal='SIGINT',
init=True, init=True,