Make sql database persistent

This commit is contained in:
Ondřej 2024-02-21 18:06:57 +01:00
parent 8f935bf160
commit aa8a5027d2
5 changed files with 12 additions and 7 deletions

1
.dockerignore Normal file
View file

@ -0,0 +1 @@
node_modules/

View file

@ -3,9 +3,11 @@ FROM denoland/deno:1.40.2
ARG GIT_REVISION
ENV DENO_DEPLOYMENT_ID=${GIT_REVISION}
RUN mkdir -p /var/sqlite
WORKDIR /app
ADD . /app
ADD . .
RUN deno cache main.ts
RUN deno task build
@ -13,4 +15,4 @@ RUN deno task migrate up
EXPOSE 8000
CMD ["run", "-A", "--unstable-ffi", "main.ts"]
CMD ["task", "start"]

View file

@ -4,4 +4,6 @@ services:
ports:
- "8000:8000"
volumes:
- .:/app
- sqlite_data:/var/sqlite
volumes:
sqlite_data:

View file

@ -4,9 +4,9 @@
"check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
"cli": "echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -",
"manifest": "deno task cli manifest $(pwd)",
"start": "deno run -A --unstable-ffi --watch=static/,routes/,src/ dev.ts",
"dev": "deno run -A --unstable-ffi --watch=static/,routes/,src/ dev.ts",
"build": "deno run -A --unstable-ffi dev.ts build",
"preview": "deno run -A --unstable-ffi main.ts",
"start": "deno run -A --unstable-ffi main.ts",
"update": "deno run -A --unstable-ffi -r https://fresh.deno.dev/update .",
"migrate": "deno run -A --unstable-ffi scripts/migrate.ts",
"ttag": "deno run -A --unstable-ffi npm:ttag-cli",

View file

@ -1,9 +1,9 @@
import { Kysely } from "kysely";
import { Database } from "sqlite3";
import { SqliteDialect } from "kysely-deno-sqlite3";
import { join } from "$std/path/join.ts";
const path = join(Deno.cwd(), "db.sqlite");
const path = Deno.env.get("DATABASE_PATH") ??
"/var/sqlite/reset_sender_v2.sqlite";
const sqlite = new Database(path);
sqlite.exec("PRAGMA journal_mode = WAL;");