Fix docker
This commit is contained in:
parent
b1b91afab5
commit
07f0999a3d
5 changed files with 25 additions and 9 deletions
|
@ -10,7 +10,6 @@ RUN npm install
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN npm run migrate
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
ENV HOST=0.0.0.0
|
ENV HOST=0.0.0.0
|
||||||
|
|
16
compose.yaml
16
compose.yaml
|
@ -4,8 +4,18 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
environment:
|
environment:
|
||||||
DATABASE_PATH: /var/sqlite/reset-sender-v2.sqlite
|
DATABASE_URL: postgres://reset_sender_v2:reset_sender_v2@postgres:5432/reset_sender_v2
|
||||||
|
postgres:
|
||||||
|
image: postgres:14-alpine
|
||||||
volumes:
|
volumes:
|
||||||
- sqlite_data:/var/sqlite
|
- postgres_data:/var/lib/postgresql/data/
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: reset_sender_v2
|
||||||
|
POSTGRES_USER: reset_sender_v2
|
||||||
|
POSTGRES_PASSWORD: reset_sender_v2
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- '5432:5432'
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
sqlite_data:
|
postgres_data:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import "dotenv/config";
|
import "dotenv/config";
|
||||||
import { drizzle } from "drizzle-orm/postgres-js";
|
|
||||||
import { migrate } from "drizzle-orm/postgres-js/migrator";
|
import { migrate } from "drizzle-orm/postgres-js/migrator";
|
||||||
import postgres from "postgres";
|
import { db, client } from "../src/db";
|
||||||
|
|
||||||
const migrationClient = postgres(process.env.DATABASE_URL!, { max: 1 });
|
await migrate(db, { migrationsFolder: "drizzle" });
|
||||||
migrate(drizzle(migrationClient), { migrationsFolder: "drizzle" });
|
|
||||||
|
await client.end();
|
||||||
|
|
|
@ -2,5 +2,11 @@ import { drizzle } from "drizzle-orm/postgres-js";
|
||||||
import postgres from "postgres";
|
import postgres from "postgres";
|
||||||
import * as schema from "./schema";
|
import * as schema from "./schema";
|
||||||
|
|
||||||
const client = postgres(import.meta.env.DATABASE_URL);
|
const DATABASE_URL = process.env.DATABASE_URL;
|
||||||
|
|
||||||
|
if (!DATABASE_URL) {
|
||||||
|
throw new Error("'DATABASE_URL' environment variable not set");
|
||||||
|
}
|
||||||
|
|
||||||
|
export const client = postgres(DATABASE_URL);
|
||||||
export const db = drizzle(client, { schema });
|
export const db = drizzle(client, { schema });
|
||||||
|
|
|
@ -27,4 +27,5 @@ export const messages = pgTable("messages", {
|
||||||
from: text("from").notNull(),
|
from: text("from").notNull(),
|
||||||
to: text("to").notNull(),
|
to: text("to").notNull(),
|
||||||
status: statusEnum("status").notNull(),
|
status: statusEnum("status").notNull(),
|
||||||
|
foo: text("foo"),
|
||||||
});
|
});
|
||||||
|
|
Reference in a new issue