Replies: 4 comments
-
|
Would love to hear your feedback @marcvergees @vharkins1 @abhishek-8081 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Sounds good to us, greenlight to go ahead with option 1. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Closing this discussion as the migration is made and PR is merged. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
FireForm currently uses SQLite as its database. The database file (
fireform.db) lives inside a Docker volume and is accessed directly by the app container. This works for a single developer running things locally, but it falls apart when we think about real deployments.SQLite allows only one writer at a time. If two API requests try to write to the database at the same time, one of them has to wait. With gunicorn running multiple workers in production (which we already do see
WEB_CONCURRENCYin the prod compose file), this becomes a real problem. Multiple workers means multiple processes trying to write to the same SQLite file, and that leads to lock contention and failed requests.Beyond concurrency, there is a real risk of data loss with the current setup. The SQLite file lives inside a Docker volume. If the container gets recreated, the volume gets accidentally pruned, or someone runs
docker compose down -v(which we even expose asmake super-clean), the entire database is gone. Even with volumes mounted properly, Docker volumes are not a reliable storage layer for production data. There is no built-in replication, no point-in-time recovery, no automated backups, and no way to recover if the host machine fails. For a tool that stores form templates and submission records for organisations, losing that data is not acceptable.Proposal
Switch to PostgreSQL. This has two parts - how we handle it in development and how we handle it in production. These are intentionally different because the requirements are different.
Part 1: Development - PostgreSQL in Docker Compose
For local development, we add a
postgresservice directly indocker/dev/compose.yml. This keeps the developer experience simple - you runmake fireformand everything comes up, including the database.The service would look something like this:
And in
.env.dev:The app container would
depends_onpostgres withcondition: service_healthy, same pattern we already use for ollama. For development, we mount the postgres data to a Docker volume. If the volume gets wiped, it does not matter since this is just local dev data that can be recreated by restarting the app (seed data gets re-inserted on startup viainit_db()).Part 2: Production - External PostgreSQL, NOT in Docker
This is the important part. We should NOT run PostgreSQL inside Docker in production.
Running a database in a Docker container in production is generally a bad idea for several reasons:
docker compose down -vor a volume driver issue can wipe production data permanently.The bottom line is that production data needs to live in a system designed to keep it safe. Docker is not that system.
For production, organisations deploying FireForm should use a proper PostgreSQL instance outside of Docker. This could be:
Either way, the database lives outside of Docker, managed by systems that are actually built for data durability, automated backups, replication, and recovery. From FireForm's perspective, the only thing that changes is the
DATABASE_URLin.env.prod. That is the whole point of this design. The application code does not care where PostgreSQL is running.The production compose file (
docker/prod/compose.yml) would not include a postgres service. It stays as-is with just ollama, whisper, and the app. The app just needs the database URL:This means the prod deployment instructions would be something like:
fireform.env.prodasDATABASE_URLmake fireform- the app handles table creation on startup viainit_db()Beta Was this translation helpful? Give feedback.
All reactions