Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
PAStheLoD opened this Issue Jul 4, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@PAStheLoD
Copy link

PAStheLoD commented Jul 4, 2018

General information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): docker 17.12.0-ce on CentOS 7
  • ElasticHQ Version: v3.4.0 (current latest, 9f821357c54a)
  • Elasticsearch Version: N/A
  • Python version: N/A
  • Browser Vendor and Version (if applicable): N/A

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

This comment has been minimized.

Copy link
Member

royrusso commented Jul 5, 2018

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

@royrusso royrusso added the enhancement label Jul 5, 2018

@royrusso royrusso added this to the 3.4.1 milestone Jul 5, 2018

@PAStheLoD

This comment has been minimized.

Copy link
Author

PAStheLoD commented Jul 5, 2018

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

This comment has been minimized.

Copy link
Member

royrusso commented Jul 13, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.