I’m new to fly, and relatively new to both docker and sqlite.
I’m able to deploy my app, with a volume. The sqlite db is baked into the docker image (COPY orders.db /app/).
To create the volume using fly, I had to add to the toml:
[mounts]
source="my_data"
destination="/data"
I don’t want to use litefs (yet); I’m fine with the db being bound to the machine. However, it clearly needs to live on the volume rather than on the vm’s storage. So here are my questions:
How do I move orders.db from the container’s /app directory to the volume? Is that the responsibility of my application?
If the latter, is there a pattern I should follow for testing the docker container locally? Can I simulate the /data/ volume in my docker container within that clobbering fly’s volume mount?
Do you have to copy the local file into the docker image cause in typical setups this PITA? You don’t want your mutable data in your build artifacts.
You can just move it at /data/orders.db. For my own applications I usually just read from DATABASE_URL environment variable then I swap it out depending on whether I’m dev or in production.
That depends on whether you want to to keep the data around or not but that what docker volumes are for. You’re probably find better resources for how to configure your specific environment on the internet.
Do you have to copy the local file into the docker image cause in typical setups this PITA? You don’t want your mutable data in your build artifacts.
It’s just an empty template, not mutable data. However, obviously I don’t want to overwrite it.
Does fly have a recommended way to initialize a volume? If I could copy orders.db (blank) to the volume on application initialization, that would work. Obviously I can also init a new database if one doesn’t exist, but that seems a bit annoying.