Skip to content

Make SQLite temp files work on a read-only root #1972

Open

Description

@aaronbrethorst

SQLite writes temp files (sorts, temp B-trees, large transactions) to a directory that the unix VFS chooses: SQLITE_TMPDIR, then TMPDIR, then /var/tmp, /usr/tmp, /tmp and .. It reads the two environment variables once, at OS init. On a container with a read-only root filesystem, none of the default directories may be writable, so a large import can fail.

Make the temp directory a deployment setting, not code in gtfsdb. For example, set TMPDIR (or SQLITE_TMPDIR) to a writable volume in the Dockerfile and the docker-compose files, and document it in the README. Setting the variable from createDB is not reliable, because SQLite reads it only once per process.

Found in review of #1677, which keeps the default file-backed temp storage (temp_store is not changed).

Activity

  1. Ashu-300 commented on Nov 9, 2026

    @Ashu-300

    Hi @aaronbrethorst ,

    I noticed this is self-assigned—are you currently working on this, or would you like me to open a PR?

    I have the proposed changes drafted:

    Dockerfile & Dockerfile.dev: Ensure /app/data/tmp exists with proper ownership (chown -R maglev:maglev), and set ENV TMPDIR=/app/data/tmp so SQLite directs temp spill files to the writable volume instead of the read-only root /tmp.
    Docker Compose: Add TMPDIR: /app/data/tmp to the environment: section in both docker-compose.yml and docker-compose.dev.yml.
    Documentation: Update README.markdown to document deployment guidance for read-only root container environments.

    Happy to open a PR with these updates if you'd like!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions