diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..31fda85 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules/ +.svelte-kit/ +build/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b51fc73 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM oven/bun AS builder + +WORKDIR /app + +COPY . . + +RUN apt update +RUN apt install build-essential python3 -y + +RUN bun i +RUN bun run build + +RUN ls -a + +FROM oven/bun + +COPY --from=builder /app/build . +COPY --from=builder /app/drizzle . +COPY --from=builder /app/drizzle.config.ts . +COPY /local.db . + +EXPOSE 3000 + +CMD ["bun", "run", "start"] diff --git a/bun.lockb b/bun.lockb index 33391d2..cb71060 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..38b3b4e --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,13 @@ +version: '0.1.0' +services: + external: + container_name: ferdinland_beta + # The name of the image that will be created when building this container + image: themodrnhakr/ferdinland_beta + build: + context: . + dockerfile: Dockerfile + environment: + - DATABASE_URL=local.db + ports: + - 8080:3000 diff --git a/drizzle/0000_youthful_sway.sql b/drizzle/0000_youthful_sway.sql new file mode 100644 index 0000000..5b08e55 --- /dev/null +++ b/drizzle/0000_youthful_sway.sql @@ -0,0 +1,15 @@ +CREATE TABLE `session` ( + `id` text PRIMARY KEY NOT NULL, + `user_id` text NOT NULL, + `expires_at` integer NOT NULL, + FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action +); +--> statement-breakpoint +CREATE TABLE `user` ( + `id` text PRIMARY KEY NOT NULL, + `age` integer, + `username` text NOT NULL, + `password_hash` text NOT NULL +); +--> statement-breakpoint +CREATE UNIQUE INDEX `user_username_unique` ON `user` (`username`); \ No newline at end of file diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json new file mode 100644 index 0000000..df43b49 --- /dev/null +++ b/drizzle/meta/0000_snapshot.json @@ -0,0 +1,106 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "e61f6036-2b90-47d1-a92c-e66fa8f4cba6", + "prevId": "00000000-0000-0000-0000-000000000000", + "tables": { + "session": { + "name": "session", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "age": { + "name": "age", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "user_username_unique": { + "name": "user_username_unique", + "columns": [ + "username" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json new file mode 100644 index 0000000..042b7ff --- /dev/null +++ b/drizzle/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "sqlite", + "entries": [ + { + "idx": 0, + "version": "6", + "when": 1734840812601, + "tag": "0000_youthful_sway", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..f67b2c6 --- /dev/null +++ b/index.ts @@ -0,0 +1 @@ +console.log("Hello via Bun!"); \ No newline at end of file diff --git a/package.json b/package.json index 7603766..fc1137b 100644 --- a/package.json +++ b/package.json @@ -18,30 +18,32 @@ "db:studio": "drizzle-kit studio" }, "devDependencies": { - "@eslint/compat": "^1.2.3", - "@sveltejs/adapter-node": "^5.2.9", - "@sveltejs/kit": "^2.0.0", - "@sveltejs/vite-plugin-svelte": "^4.0.0", - "@types/better-sqlite3": "^7.6.11", - "drizzle-kit": "^0.22.0", - "eslint": "^9.7.0", + "@eslint/compat": "^1.2.4", + "@sveltejs/adapter-node": "^5.2.11", + "@sveltejs/kit": "^2.15.0", + "@sveltejs/vite-plugin-svelte": "^5.0.3", + "@types/bun": "latest", + "drizzle-kit": "^0.30.1", + "eslint": "^9.17.0", "eslint-config-prettier": "^9.1.0", - "eslint-plugin-svelte": "^2.36.0", - "globals": "^15.0.0", - "prettier": "^3.3.2", - "prettier-plugin-svelte": "^3.2.6", - "svelte": "^5.0.0", - "svelte-check": "^4.0.0", - "typescript": "^5.0.0", - "typescript-eslint": "^8.0.0", - "vite": "^5.4.11", - "vitest": "^2.0.4" + "eslint-plugin-svelte": "^2.46.1", + "globals": "^15.14.0", + "prettier": "^3.4.2", + "prettier-plugin-svelte": "^3.3.2", + "svelte": "^5.15.0", + "svelte-adapter-bun": "^0.5.2", + "svelte-check": "^4.1.1", + "typescript": "^5.7.2", + "typescript-eslint": "^8.18.1", + "vite": "^6.0.5", + "vitest": "^2.1.8" }, "dependencies": { - "@node-rs/argon2": "^1.1.0", + "@libsql/client": "^0.14.0", + "@node-rs/argon2": "^2.0.2", "@oslojs/crypto": "^1.0.1", "@oslojs/encoding": "^1.1.0", - "better-sqlite3": "^11.1.2", - "drizzle-orm": "^0.33.0" - } + "drizzle-orm": "^0.38.2" + }, + "module": "index.ts" } diff --git a/src/lib/server/db/index.ts b/src/lib/server/db/index.ts index 205b05b..7a1ca94 100644 --- a/src/lib/server/db/index.ts +++ b/src/lib/server/db/index.ts @@ -1,5 +1,5 @@ -import { drizzle } from 'drizzle-orm/better-sqlite3'; -import Database from 'better-sqlite3'; +import { drizzle } from 'drizzle-orm/bun-sqlite'; +import Database from 'bun:sqlite'; import { env } from '$env/dynamic/private'; if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set'); const client = new Database(env.DATABASE_URL); diff --git a/svelte.config.js b/svelte.config.js index e0a641e..1d5479b 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,4 +1,4 @@ -import adapter from '@sveltejs/adapter-node'; +import adapter from 'svelte-adapter-bun'; import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; /** @type {import('@sveltejs/kit').Config} */