mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
Finish full migration to Drizzle
This commit is contained in:
parent
0ca77e9dcc
commit
b1ee6e5684
7
.github/workflows/tests.yml
vendored
7
.github/workflows/tests.yml
vendored
|
|
@ -44,13 +44,6 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
mv .github/config.workflow.toml config/config.toml
|
mv .github/config.workflow.toml config/config.toml
|
||||||
|
|
||||||
- name: Generate Prisma Client
|
|
||||||
run: |
|
|
||||||
bunx prisma generate
|
|
||||||
|
|
||||||
- name: Migrate database
|
|
||||||
run: bun migrate
|
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
bun test
|
bun test
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,7 @@ COPY . /temp
|
||||||
COPY --from=install /temp/node_modules /temp/node_modules
|
COPY --from=install /temp/node_modules /temp/node_modules
|
||||||
# Build the project
|
# Build the project
|
||||||
WORKDIR /temp
|
WORKDIR /temp
|
||||||
RUN bunx --bun prisma generate
|
|
||||||
RUN bun run prod-build
|
RUN bun run prod-build
|
||||||
COPY prisma /temp/dist
|
|
||||||
WORKDIR /temp/dist
|
WORKDIR /temp/dist
|
||||||
|
|
||||||
# copy production dependencies and source code into final image
|
# copy production dependencies and source code into final image
|
||||||
|
|
|
||||||
3
build.ts
3
build.ts
|
|
@ -32,6 +32,9 @@ await Bun.build({
|
||||||
// I apologize for this
|
// I apologize for this
|
||||||
await $`sed -i 's|import("node_modules/|import("./node_modules/|g' dist/*.js`;
|
await $`sed -i 's|import("node_modules/|import("./node_modules/|g' dist/*.js`;
|
||||||
|
|
||||||
|
// Copy Drizzle migrations to dist
|
||||||
|
await $`cp -r drizzle dist/drizzle`;
|
||||||
|
|
||||||
// Copy Sharp to dist
|
// Copy Sharp to dist
|
||||||
await $`mkdir -p dist/node_modules/@img`;
|
await $`mkdir -p dist/node_modules/@img`;
|
||||||
await $`cp -r node_modules/@img/sharp-libvips-linux-* dist/node_modules/@img`;
|
await $`cp -r node_modules/@img/sharp-libvips-linux-* dist/node_modules/@img`;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// import { config } from "config-manager";
|
import { config } from "config-manager";
|
||||||
import type { Config } from "drizzle-kit";
|
import type { Config } from "drizzle-kit";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -6,19 +6,12 @@ export default {
|
||||||
out: "./drizzle",
|
out: "./drizzle",
|
||||||
schema: "./drizzle/schema.ts",
|
schema: "./drizzle/schema.ts",
|
||||||
dbCredentials: {
|
dbCredentials: {
|
||||||
host: "localhost",
|
|
||||||
port: 40003,
|
|
||||||
user: "lysand",
|
|
||||||
password: "lysand",
|
|
||||||
database: "lysand",
|
|
||||||
},
|
|
||||||
/* dbCredentials: {
|
|
||||||
host: config.database.host,
|
host: config.database.host,
|
||||||
port: Number(config.database.port),
|
port: Number(config.database.port),
|
||||||
user: config.database.username,
|
user: config.database.username,
|
||||||
password: config.database.password,
|
password: config.database.password,
|
||||||
database: config.database.database,
|
database: config.database.database,
|
||||||
}, */
|
},
|
||||||
// Print all statements
|
// Print all statements
|
||||||
verbose: true,
|
verbose: true,
|
||||||
// Always ask for confirmation
|
// Always ask for confirmation
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
# Commands:
|
# Commands:
|
||||||
# - `start`: Starts the server
|
# - `start`: Starts the server
|
||||||
# - `cli`: Starts the CLI, sends all arguments to it
|
# - `cli`: Starts the CLI, sends all arguments to it
|
||||||
# - `prisma`: Execute a Prisma command, sends
|
|
||||||
|
|
||||||
# Exit immediately if a command exits with a non-zero status.
|
# Exit immediately if a command exits with a non-zero status.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
@ -14,8 +13,6 @@ cd /app/dist
|
||||||
# Parse first argument
|
# Parse first argument
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"start")
|
"start")
|
||||||
# Migrate the database and run
|
|
||||||
/bin/bash /app/entrypoint.sh prisma migrate deploy
|
|
||||||
NITRO_PORT=5173 bun run ./frontend/server/index.mjs & NODE_ENV=production bun run ./index.js --prod
|
NITRO_PORT=5173 bun run ./frontend/server/index.mjs & NODE_ENV=production bun run ./index.js --prod
|
||||||
;;
|
;;
|
||||||
"cli")
|
"cli")
|
||||||
|
|
@ -23,15 +20,6 @@ case "$1" in
|
||||||
shift 1
|
shift 1
|
||||||
bun run ./cli.js "$@"
|
bun run ./cli.js "$@"
|
||||||
;;
|
;;
|
||||||
"prisma")
|
|
||||||
# Proxy all Prisma commands
|
|
||||||
# Use output of dist/prisma.js to get the env variable
|
|
||||||
shift 1
|
|
||||||
# Set DATABASE_URL env variable to the output of bun run ./dist/prisma.js
|
|
||||||
export DATABASE_URL=$(bun run ./prisma.js)
|
|
||||||
# Execute the Prisma binary
|
|
||||||
bun run ./node_modules/.bin/prisma "$@"
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
# Run custom commands
|
# Run custom commands
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,8 @@
|
||||||
"fe:build": "bun --bun nuxt build packages/frontend",
|
"fe:build": "bun --bun nuxt build packages/frontend",
|
||||||
"fe:analyze": "bun --bun nuxt analyze packages/frontend",
|
"fe:analyze": "bun --bun nuxt analyze packages/frontend",
|
||||||
"start": "NITRO_PORT=5173 bun run dist/frontend/server/index.mjs & NODE_ENV=production bun run dist/index.js --prod",
|
"start": "NITRO_PORT=5173 bun run dist/frontend/server/index.mjs & NODE_ENV=production bun run dist/index.js --prod",
|
||||||
"migrate-dev": "bun prisma migrate dev",
|
|
||||||
"migrate": "bun prisma migrate deploy",
|
|
||||||
"lint": "bunx --bun eslint --config .eslintrc.cjs --ext .ts .",
|
"lint": "bunx --bun eslint --config .eslintrc.cjs --ext .ts .",
|
||||||
"prod-build": "bun run build.ts",
|
"prod-build": "bun run build.ts",
|
||||||
"prisma": "DATABASE_URL=$(bun run prisma.ts) bunx prisma",
|
|
||||||
"generate": "bun prisma generate",
|
|
||||||
"benchmark:timeline": "bun run benchmarks/timelines.ts",
|
"benchmark:timeline": "bun run benchmarks/timelines.ts",
|
||||||
"cloc": "cloc . --exclude-dir node_modules,dist,.output,.nuxt,meta,logs --exclude-ext sql,log",
|
"cloc": "cloc . --exclude-dir node_modules,dist,.output,.nuxt,meta,logs --exclude-ext sql,log",
|
||||||
"cli": "bun run cli.ts"
|
"cli": "bun run cli.ts"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
import { config } from "config-manager";
|
|
||||||
|
|
||||||
// Proxies all `bunx prisma` commands with an environment variable
|
|
||||||
|
|
||||||
process.stdout.write(
|
|
||||||
`postgresql://${config.database.username}:${config.database.password}@${config.database.host}:${config.database.port}/${config.database.database}\n`,
|
|
||||||
);
|
|
||||||
|
|
||||||
process.exit(0);
|
|
||||||
Loading…
Reference in a new issue