ElasticHQ / elasticsearch-HQ

Monitoring and Management Web Application for ElasticSearch instances and clusters.
http://www.elastichq.org
Other
4.96k stars 532 forks source link

RFE: Put SQLite DB into a directory, so it can be hosted on docker volume (so it survives an image upgrade) #409

Closed PAStheLoD closed 6 years ago

PAStheLoD commented 6 years ago

General information

Issue Description

Currently recreating a docker container containing an elastichq.db results in the loss of that file, and without an ugly workaround it's hard to relocate that file.

Source Code / Logs

The location of elastichq.db is hardcoded into ProdSettings: https://github.com/ElasticHQ/elasticsearch-HQ/blob/master/elastichq/config/settings.py#L117

Probable drawbacks

Of course, maybe this might require SQL Alchemy migrations.

royrusso commented 6 years ago

This may be possible using an external settings.json.... this needs to be documented but is already supported. I have an open issue for this, and will update this when I've tested it. #407

PAStheLoD commented 6 years ago

That'd require mounting and maintaining an external settings file.

I currently use this "one liner" to put the DB file into a directory. ("db" already exists, it's just empty for some reason.)

docker run --detach \
           --restart=always \
           --net host \
           --volume elastichq:/src/db \
           --name elastichq \
           elastichq/elasticsearch-hq \
           sh -x -c 'sed -i -r -e "s/_sqlalchemy_database_uri =.*/_sqlalchemy_database_uri = \"sqlite:\/\/\/\" + os.path.join(BASEPATH, \"db\" , \"elastichq.db\")/" /src/elastichq/config/settings.py && exec supervisord -c /etc/supervisor/supervisord.conf'
royrusso commented 6 years ago

That's a heck of a one-liner. I will add this to the docs as well.

wjwGeronimo commented 4 years ago

docker run -d -p 5000:5000 --mount type=bind,source="$(pwd)"/elastichq.db,target=/src/elastichq.db elastichq/elasticsearch-hq:release-v3.5.12