Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ RUN DATABASE_URL="postgresql://user:password@localhost:5432/forums" pnpm prisma:
&& pnpm lint \
&& pnpm build \
&& rm -rf node_modules \
&& pnpm install --prod --frozen-lockfile --ignore-scripts
&& pnpm install --prod --frozen-lockfile --ignore-scripts \
&& pnpm rebuild @prisma/engines

FROM node:${NODE_VERSION}-alpine AS production

Expand All @@ -52,7 +53,11 @@ WORKDIR /usr/src/app
COPY --from=build --chown=node:node /usr/src/app/dist ./dist
COPY --from=build --chown=node:node /usr/src/app/node_modules ./node_modules
COPY --from=build --chown=node:node /usr/src/app/prisma/generated ./prisma/generated
COPY --from=build --chown=node:node /usr/src/app/prisma/migrations ./prisma/migrations
COPY --from=build --chown=node:node /usr/src/app/prisma/schema.prisma ./prisma/schema.prisma
COPY --from=build --chown=node:node /usr/src/app/prisma.config.ts ./prisma.config.ts
COPY --from=build --chown=node:node /usr/src/app/package.json ./package.json
COPY --from=build --chown=node:node --chmod=0555 /usr/src/app/appStartUp.sh ./appStartUp.sh
COPY --from=external-clients --chown=node:node /clients/challenge-api-v6/packages/challenge-prisma-client /usr/src/challenge-api-v6/packages/challenge-prisma-client
COPY --from=external-clients --chown=node:node /clients/identity-api-v6/packages/identity-prisma-client /usr/src/identity-api-v6/packages/identity-prisma-client
COPY --from=external-clients --chown=node:node /clients/member-api-v6/packages/member-prisma-client /usr/src/member-api-v6/packages/member-prisma-client
Expand All @@ -61,4 +66,4 @@ COPY --from=external-clients --chown=node:node /clients/resource-api-v6/packages
USER node
EXPOSE 3000

CMD ["node", "dist/main.js"]
CMD ["./appStartUp.sh"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,6 @@ interrupted, wipe the target forums dataset and rerun the full import.

The forums Prisma schema defines `Topic`, `Post`, `PostReaction`, `TopicClosure`, `TopicWatch`, `TopicReadState`, `MemberBan`, and `IpBan` in the dedicated `forums` schema. `PostReaction` uses a composite post/member key so each member has at most one thumbs-up or thumbs-down value per post; deleting a post cascades its reactions. Topics store an explicit lock state plus nullable lock timestamp and lock actor member id. Ban rows keep active and removed audit metadata; the migration enforces one active row per member or exact IP value and validates IP bans as single IPv4/IPv6 host values. `pnpm prisma:generate` emits the local client at `prisma/generated/client` and the reusable exported client at `packages/forums-prisma-client`.

The production image includes the Prisma schema, migration history, configuration, and CLI. Its startup script runs `prisma migrate deploy` before starting NestJS, so a deployment cannot begin serving requests against an older forums schema. Migration failure stops the container instead of leaving feature-dependent reads or writes partially available.

Topic creation is transactional: it creates the topic, starter post, closure rows, and, for human authors, author watch and read-state rows together. M2M topic creation uses the system author and skips member watch/read-state side effects. Topic deletion is soft deletion, and post deletion preserves the post row while setting content to null for placeholder reads. Topic summary reads use side-effect-free raw queries for topic lock state, visible-post counts, nullable latest visible activity, and unread derivation, then apply centralized forums policy filtering before pagination.
8 changes: 8 additions & 0 deletions appStartUp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -eu

printf '%s\n' 'Applying forums database migrations.'
./node_modules/.bin/prisma migrate deploy

printf '%s\n' 'Starting Forums API v6.'
exec node dist/main.js
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"express": "^5.1.0",
"mysql2": "^3.14.3",
"pg": "^8.16.3",
"prisma": "^7.9.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2",
"tc-bus-api-wrapper": "github:topcoder-platform/tc-bus-api-wrapper",
Expand All @@ -51,7 +52,6 @@
"globals": "^16.3.0",
"jest": "^29.7.0",
"prettier": "^3.4.2",
"prisma": "^7.9.0",
"supertest": "^7.0.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

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

Loading