configure for docker

This commit is contained in:
themodernhakr 2024-12-23 00:06:26 -06:00
parent 4046379185
commit 567380422f
11 changed files with 201 additions and 24 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
node_modules/
.svelte-kit/
build/

24
Dockerfile Normal file
View File

@ -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"]

BIN
bun.lockb

Binary file not shown.

13
docker-compose.yaml Normal file
View File

@ -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

View File

@ -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`);

View File

@ -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": {}
}
}

View File

@ -0,0 +1,13 @@
{
"version": "7",
"dialect": "sqlite",
"entries": [
{
"idx": 0,
"version": "6",
"when": 1734840812601,
"tag": "0000_youthful_sway",
"breakpoints": true
}
]
}

1
index.ts Normal file
View File

@ -0,0 +1 @@
console.log("Hello via Bun!");

View File

@ -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"
}

View File

@ -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);

View File

@ -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} */