Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
junlarsen committed Mar 4, 2025
1 parent 3d22e16 commit 900bec7
Show file tree
Hide file tree
Showing 32 changed files with 65 additions and 67 deletions.
7 changes: 6 additions & 1 deletion apps/dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ ENV DOCKER_BUILD=1

RUN npm install -g [email protected] [email protected] --ignore-scripts
COPY --from=builder /app/out/json .
RUN pnpm install --ignore-scripts
COPY --from=builder /app/out/full/packages/db/prisma/schema.prisma packages/db/prisma/schema.prisma

# Must enable scripts here for Prisma codegen to build
RUN apk update && apk add --no-cache python3 gcc g++ make
RUN pnpm install

COPY --from=builder /app/out/full .
RUN turbo run build --filter @dotkomonline/dashboard

Expand Down
11 changes: 6 additions & 5 deletions apps/rpc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ COPY --from=builder /app/out/full/packages/db/prisma/schema.prisma packages/db/p
# Must enable scripts here for Prisma codegen to build
RUN apk update && apk add --no-cache python3 gcc g++ make
RUN pnpm install
COPY --from=builder /app/out/full .
RUN turbo run build --filter @dotkomonline/rpc

# Install for production
RUN pnpm install --production

FROM base AS runner
WORKDIR /app
Expand All @@ -38,7 +39,7 @@ RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 rpc
USER rpc

COPY --from=installer --chown=nodejs:rpc --chmod=755 /app/apps/rpc/dist/index.js ./
COPY --from=installer --chown=nodejs:rpc --chmod=755 /app/apps/rpc/package.json ./
COPY --from=installer --chown=rpc:nodejs --chmod=755 /app .
COPY --from=builder --chown=rpc:nodejs --chmod=755 /app/out/full .

CMD node index.js
CMD node --loader ./apps/rpc/runtime.mjs --experimental-strip-types ./apps/rpc/src/index.ts
3 changes: 0 additions & 3 deletions apps/rpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"type": "module",
"scripts": {
"dev": "dotenv -o -- tsx watch src/index.ts",
"build": "tsup src/index.ts",
"docker:build": "docker build --platform linux/amd64 -t rpc:latest -f Dockerfile --progress plain ../..",
"lint": "biome check . --write",
"lint-check": "biome check .",
Expand All @@ -30,8 +29,6 @@
"@types/node": "^22.0.0",
"dotenv-cli": "^8.0.0",
"tslib": "^2.6.2",
"tsup": "^8.3.0",
"tsx": "^4.15.6",
"typescript": "^5.8"
}
}
3 changes: 1 addition & 2 deletions apps/rpc/runtime.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { URL } from "node:url"
import { existsSync } from "node:fs"
import path from "node:path"
import { URL } from "node:url"

export async function resolve(specifier, context, nextResolve) {
// Only handle relative or absolute paths without extensions
Expand Down
15 changes: 0 additions & 15 deletions apps/rpc/tsup.config.ts

This file was deleted.

5 changes: 2 additions & 3 deletions packages/core/src/modules/attendance/attendance-repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DBClient } from "@dotkomonline/db"
import { type DBClient, PrismaRuntime } from "@dotkomonline/db"
import {
type Attendance,
type AttendanceId,
Expand All @@ -7,7 +7,6 @@ import {
type Extras,
ExtrasSchema,
} from "@dotkomonline/types"
import { Prisma } from "@dotkomonline/db"
import type { JsonValue } from "@prisma/client/runtime/library"

export interface AttendanceRepository {
Expand Down Expand Up @@ -80,7 +79,7 @@ export class AttendanceRepositoryImpl implements AttendanceRepository {

/** Prisma requires distinction between database null and json null, so here we choose database null */
private correctNullTypes<T extends { extras?: unknown }>(data: T) {
return { ...data, extras: data.extras === null ? Prisma.DbNull : data.extras }
return { ...data, extras: data.extras === null ? PrismaRuntime.DbNull : data.extras }
}

/** Takes an object with unparsed JSON value yearCriteria and returns it with yearCriteria parsed */
Expand Down
14 changes: 11 additions & 3 deletions packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
"name": "@dotkomonline/db",
"version": "1.0.0",
"type": "module",
"main": "./src/index.ts",
"types": "./src/index.ts",
"private": true,
"files": ["prisma/schema.prisma"],
"exports": {
".": {
"import": "./src/index.ts",
"types": "./src/index.ts"
},
"./schemas": {
"import": "./src/schemas.ts",
"types": "./src/schemas.ts"
}
},
"scripts": {
"clean": "rm -rf .turbo node_modules",
"lint": "biome check . --write",
Expand All @@ -28,6 +35,7 @@
"devDependencies": {
"@biomejs/biome": "^1.9.3",
"@dotkomonline/config": "workspace:*",
"@types/node": "^22.0.0",
"@types/pg": "^8.10.9",
"prisma": "^6.3.1",
"tsx": "^4.19.3",
Expand Down
5 changes: 3 additions & 2 deletions packages/db/src/fixtures/attendance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Prisma } from "../index"
import type { Prisma } from "@prisma/client"
import { PrismaRuntime } from "../index"

export const getAttendanceFixtures = (): Prisma.AttendanceCreateManyInput[] => [
{
Expand Down Expand Up @@ -52,6 +53,6 @@ export const getAttendanceFixtures = (): Prisma.AttendanceCreateManyInput[] => [
deregisterDeadline: new Date("2023-02-23 11:03:49.289+00"),
createdAt: new Date("2023-02-23 11:03:49.289+00"),
updatedAt: new Date("2023-02-23 11:03:49.289+00"),
extras: Prisma.DbNull,
extras: PrismaRuntime.DbNull,
},
]
13 changes: 6 additions & 7 deletions packages/db/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { createRequire } from "node:module"
import type { Prisma, PrismaClient } from "@prisma/client"
import type { DefaultArgs } from "@prisma/client/runtime/library"

const require = createRequire(import.meta.url)
const { Prisma, PrismaClient } = require("@prisma/client")
export * as schemas from "./schemas/index"
const { Prisma: _Prisma, PrismaClient: _PrismaClient } = require("@prisma/client")
export type * from "@prisma/client"
export { Prisma, PrismaClient }

import type { Prisma as _Prisma, PrismaClient as _PrismaClient } from "@prisma/client"

export type DBClient = _PrismaClient<_Prisma.PrismaClientOptions, never, DefaultArgs>
export const PrismaRuntime = _Prisma
export const PrismaClientRuntime = _PrismaClient
export type DBClient = PrismaClient<Prisma.PrismaClientOptions, never, DefaultArgs>
export const createPrisma = (databaseUrl: string): DBClient =>
new PrismaClient({
new _PrismaClient({
datasourceUrl: databaseUrl,
})
1 change: 1 addition & 0 deletions packages/db/src/schemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as schemas from "./schemas/index"
2 changes: 1 addition & 1 deletion packages/db/src/test-databases.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// biome-ignore lint/style/useNodejsImportProtocol: Cannot import with node path on vercel
import { spawn } from "node:child_process"
import { spawn } from "child_process"
import { PostgreSqlContainer } from "@testcontainers/postgresql"
import { createPrisma } from "."

Expand Down
3 changes: 2 additions & 1 deletion packages/db/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../packages/config/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"declaration": true
"declaration": true,
"types": ["node"]
},
"include": ["./**/*.ts", "./**/*.tsx"]
}
1 change: 1 addition & 0 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"devDependencies": {
"@biomejs/biome": "^1.9.3",
"@dotkomonline/config": "workspace:*",
"@types/node": "^22.0.0",
"typescript": "^5.8"
}
}
2 changes: 1 addition & 1 deletion packages/types/src/article.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"
import type { z } from "zod"

export const ArticleTagSchema = schemas.ArticleTagSchema.extend({})
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/attendance/attendance-pool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"
import { z } from "zod"

export const YearCriteriaSchema = z.array(z.number())
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/attendance/attendance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"
import { z } from "zod"

export const ExtraSchema = z.object({
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/attendance/attendee.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"
import { z } from "zod"
import type { User } from "../user"

Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/attendance/waitlist-attendee.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"
import type { z } from "zod"

export const WaitlistAttendeeSchema = schemas.WaitlistAttendeeSchema.extend({})
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/committee.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { z } from "zod"

import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"

export const CommitteeSchema = schemas.CommitteeSchema.extend({})

Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/company.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"
import type { z } from "zod"

export const CompanySchema = schemas.CompanySchema.extend({})
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/event-committee.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"
import type { z } from "zod"

export const EventCommitteeSchema = schemas.EventCommitteeSchema.extend({})
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/event.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { z } from "zod"

import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"

import { type Attendance, AttendanceSchema } from "./attendance/attendance"
import type { AttendancePool } from "./attendance/attendance-pool"
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/interest-group.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { z } from "zod"

import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"

export const InterestGroupSchema = schemas.InterestGroupSchema.extend({})

Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/job-listing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"
import { z } from "zod"
import { CompanySchema } from "./company"

Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/mark.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"
import type { z } from "zod"

export const MarkSchema = schemas.MarkSchema.extend({})
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/notification-permissions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { z } from "zod"

import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"

export const NotificationPermissionsSchema = schemas.NotificationPermissionsSchema.extend({})

Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/offline.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"
import type { z } from "zod"

export const OfflineSchema = schemas.OfflineSchema.extend({})
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/payment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"
import { z } from "zod"

export const ProductPaymentProviderSchema = schemas.ProductPaymentProviderSchema.extend({})
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/personal-mark.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"
import type { z } from "zod"

export const PersonalMarkSchema = schemas.PersonalMarkSchema.extend({})
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/privacy-permissions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { schemas } from "@dotkomonline/db"
import { schemas } from "@dotkomonline/db/schemas"
import type { z } from "zod"

export const PrivacyPermissionsSchema = schemas.PrivacyPermissionsSchema.extend({})
Expand Down
3 changes: 2 additions & 1 deletion packages/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../packages/config/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"declaration": true
"declaration": true,
"types": ["node"]
},
"include": ["./**/*.ts", "./**/*.tsx"]
}
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 900bec7

Please sign in to comment.