Skip to content

Commit 0616fa7

Browse files
committed
README: Improve SQLite example
1 parent 0010875 commit 0616fa7

File tree

1 file changed

+43
-45
lines changed

1 file changed

+43
-45
lines changed

README.md

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,21 @@ All of the above are [end-to-end tested](./tests) by the CI suite in this repo!
2424
**Table of Contents**
2525

2626
- [datomic-pro-flake](#datomic-pro-flake)
27-
- [Usage - NixOS Module](#usage---nixos-module)
28-
- [`flake.nix`](#flakenix)
29-
- [`/etc/datomic-pro/secrets.properties`](#etcdatomic-prosecretsproperties)
30-
- [`configuration.nix`](#configurationnix)
31-
- [🐋 Usage - Docker (OCI) Container Image](#-usage---docker-oci-container-image)
32-
- [Transactor Mode](#transactor-mode)
33-
- [Env vars](#env-vars)
34-
- [Console Mode](#console-mode)
35-
- [Env vars](#env-vars-1)
36-
- [Example Compose](#example-compose)
37-
- [Datomic Pro with Local Storage](#datomic-pro-with-local-storage)
38-
- [Datomic Pro with Postgres Storage and memcached](#datomic-pro-with-postgres-storage-and-memcached)
39-
- [Discussion](#discussion)
40-
- [License](#license)
27+
- [Usage - NixOS Module](#usage---nixos-module)
28+
- [`flake.nix`](#flakenix)
29+
- [`/etc/datomic-pro/secrets.properties`](#etcdatomic-prosecretsproperties)
30+
- [`configuration.nix`](#configurationnix)
31+
- [🐋 Usage - Docker (OCI) Container Image](#-usage---docker-oci-container-image)
32+
- [Transactor Mode](#transactor-mode)
33+
- [Env vars](#env-vars)
34+
- [Console Mode](#console-mode)
35+
- [Env vars](#env-vars-1)
36+
- [Example Compose](#example-compose)
37+
- [Datomic Pro with Local Storage](#datomic-pro-with-local-storage)
38+
- [Datomic Pro with SQLite Storage](#datomic-pro-with-sqlite-storage)
39+
- [Datomic Pro with Postgres Storage and memcached](#datomic-pro-with-postgres-storage-and-memcached)
40+
- [Discussion](#discussion)
41+
- [License](#license)
4142

4243
<!-- markdown-toc end -->
4344

@@ -237,22 +238,32 @@ services:
237238
#user: 1000:1000 # if using rootful containers uncomment this
238239
```
239240

240-
#### Datomic Pro with sqlite storage
241-
242-
Be sure to `mkdir data/ config/` before running this.
243-
244-
And also pre-create the sqlite database:
245-
246-
``` shell
247-
mkdir -p data/ config/
248-
sqlite3 data/datomic-sqlite.db "
249-
CREATE TABLE IF NOT EXISTS datomic_kvs (
250-
id TEXT NOT NULL PRIMARY KEY,
251-
rev INTEGER,
252-
map TEXT,
253-
val BLOB
254-
);"
255-
```
241+
#### Datomic Pro with SQLite Storage
242+
243+
1. `mkdir data config`
244+
2. Prepare an empty SQLite database:
245+
246+
``` shell
247+
mkdir -p data/ config/
248+
sqlite3 data/datomic-sqlite.db "
249+
-- Tuning for SQLite in production - same as Rails 8.0
250+
PRAGMA foreign_keys = ON;
251+
PRAGMA journal_mode = WAL;
252+
PRAGMA synchronous = NORMAL;
253+
PRAGMA mmap_size = 134217728; -- 128 megabytes
254+
PRAGMA journal_size_limit = 67108864; -- 64 megabytes
255+
PRAGMA cache_size = 2000;
256+
-- Datomic's Schema
257+
CREATE TABLE datomic_kvs (
258+
id TEXT NOT NULL,
259+
rev INTEGER,
260+
map TEXT,
261+
val BYTEA,
262+
CONSTRAINT pk_id PRIMARY KEY (id)
263+
);"
264+
```
265+
266+
3. Use this compose (or pick and choose what you need)
256267

257268
``` yaml
258269
---
@@ -264,10 +275,8 @@ services:
264275
DATOMIC_SQL_URL: jdbc:sqlite:/data/datomic-sqlite.db
265276
DATOMIC_SQL_DRIVER_CLASS: org.sqlite.JDBC
266277
DATOMIC_JAVA_OPTS: -Dlogback.configurationFile=/config/logback.xml
267-
# this one is for the containers
268-
DATOMIC_HOST: datomic-transactor
269-
# this one is for the host machine
270-
DATOMIC_ALT_HOST: "127.0.0.1"
278+
DATOMIC_HOST: datomic-transactor # this value is so sibling compose containers can connect by DNS name
279+
DATOMIC_ALT_HOST: "127.0.0.1" # this value is so apps running on the container's host
271280
volumes:
272281
- "./data:/data:z"
273282
- "./config:/config:z"
@@ -284,17 +293,6 @@ services:
284293
- "./data:/data:z"
285294
ports:
286295
- 127.0.0.1:8081:8080
287-
288-
datomic-storage-migrator:
289-
image: ghcr.io/ramblurr/datomic-pro:unstable
290-
volumes:
291-
- "./data:/data:z"
292-
entrypoint: /bin/sh
293-
command: |
294-
-c '
295-
echo "Creating SQLite database and schema..."
296-
echo "Database initialization complete."
297-
'
298296
```
299297
300298
#### Datomic Pro with Postgres Storage and memcached

0 commit comments

Comments
 (0)