Dokku with SQLite?

szxk

I've read elsewhere that SQLite is not supported by Dokku. Why not? I'm using a Flask app with SQLAlchemy and it seems like that is where all the abstraction is taking place. Couldn't I just place the sqlite database file somewhere on disk (/home/dokku/database/my_db, perhaps?) and give that to SQLAlchemy?

engine = create_engine('sqlite://///home/dokku/database/my_db')

More specifically, I would use Dokku to store that string as an environmental variable, rather than pass it in directly.

Why wouldn't this work?

miraculixx

Why wouldn't this work?

Dokku creates containers via Docker, and your application runs inside this container and its file system. Besides, your flask apps doesn't have access to /home/dokku by design.

Depending on your specific needs and as long as you have a single docker container:

  • use a path inside the container (e.g. /app/db.sqlite). This works as long as the app's container exists. Note however, that for all purpose you should consider the file system of a Dokku app as temporary.

  • map a host file that is resident on the dokku host, e.g. using the dokku-persistent-storage plugin.

  • use docker data volumes. At time of writing this, there doesn't seem to be a dokku plugin, but it is relatively simple to make (needs a create command to create a data container, a link command to link it to the app, finally a dokku-args hook to generate the arguments to docker run)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related