Skip to content

Commit

Permalink
Fix the strang docker fail on rail (#467)
Browse files Browse the repository at this point in the history
* fix: use prisma service instead create a new instance

* fix: force container dependency into node_modules
  • Loading branch information
ncoquelet authored Feb 5, 2025
1 parent c8eae1e commit 0c95735
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
5 changes: 2 additions & 3 deletions apps/data-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,19 @@
"bcryptjs": "^2.4.3",
"cloudinary": "^2.5.1",
"cors": "^2.8.5",
"data-backend": "link:",
"dotenv": "^16.4.5",
"fastify": "^5.1.0",
"fastify-plugin": "^5.0.1",
"fastify-socket.io": "^5.1.0",
"fluent-ffmpeg": "^2.1.3",
"graphql": "^16.9.0",
"helmet": "^7.2.0",
"indexer-prisma": "workspace:*",
"indexer-prisma": "^1.0.0",
"jsonwebtoken": "^9.0.2",
"nodemailer": "^6.9.16",
"pg": "^8.13.1",
"pg-promise": "^11.10.1",
"prisma-db": "workspace:*",
"prisma-db": "^1.0.0",
"socket.io": "^4.8.1",
"stripe": "^17.3.1",
"telegraf": "^4.16.3",
Expand Down
2 changes: 1 addition & 1 deletion apps/nestjs-indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@nestjs/platform-express": "^10.0.0",
"@prisma/client": "^6.0.0",
"env-var": "^7.5.0",
"indexer-prisma": "workspace:*",
"indexer-prisma": "^1.0.0",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1",
"viem": "^2.21.53"
Expand Down
10 changes: 4 additions & 6 deletions apps/nestjs-indexer/src/indexer/indexer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ import { validateAndParseAddress } from 'starknet';
import constants from 'src/common/constants';
import { env } from 'src/common/env';
import { IndexerConfig } from './interfaces';
import { PrismaClient } from 'indexer-prisma';

const prisma = new PrismaClient();
import { PrismaService } from '../prisma/prisma.service';

@Injectable()
export class IndexerService {
private readonly logger = new Logger(IndexerService.name);
private readonly client: StreamClient;
private configs: IndexerConfig[] = [];

constructor() {
constructor(private readonly prismaService: PrismaService) {
this.client = new StreamClient({
url: env.indexer.dnaClientUrl,
clientOptions: {
Expand All @@ -47,7 +45,7 @@ export class IndexerService {

this.logger.log('Starting indexer...');

const indexerStats = await prisma.indexerStats.findFirst({
const indexerStats = await this.prismaService.indexerStats.findFirst({
orderBy: { lastBlockScraped: 'desc' },
});

Expand Down Expand Up @@ -129,7 +127,7 @@ export class IndexerService {
hash = FieldElement.toHex(event.receipt.transactionHash);
}

await prisma.indexerStats.create({
await this.prismaService.indexerStats.create({
data: {
lastBlockScraped: Number(block.header.blockNumber),
lastTx: hash,
Expand Down
6 changes: 3 additions & 3 deletions railway.data-backend.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ WORKDIR /app

# Copy the node_modules and built files from the base stage
COPY --from=base /app/node_modules ./node_modules
COPY --from=base /app/packages/common ./packages/common
COPY --from=base /app/packages/prisma-db ./packages/prisma-db
COPY --from=base /app/packages/indexer-prisma ./packages/indexer-prisma
COPY --from=base /app/packages/common ./node_modules/common
COPY --from=base /app/packages/prisma-db ./node_modules/prisma-db
COPY --from=base /app/packages/indexer-prisma ./node_modules/indexer-prisma
COPY --from=base /app/apps/data-backend/dist ./apps/data-backend/dist

# Copy only necessary files for the application to run
Expand Down
4 changes: 2 additions & 2 deletions railway.indexer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ WORKDIR /app

# Copy the node_modules and built files from the base stage
COPY --from=base /app/node_modules ./node_modules
COPY --from=base /app/packages/common ./packages/common
COPY --from=base /app/packages/indexer-prisma ./packages/indexer-prisma
COPY --from=base /app/packages/common ../node_modules/common
COPY --from=base /app/packages/indexer-prisma ././node_modules/indexer-prisma
COPY --from=base /app/apps/nestjs-indexer/dist ./apps/nestjs-indexer/dist

# Copy only necessary files for the application to run
Expand Down

0 comments on commit 0c95735

Please sign in to comment.