forked from Shonen-Labs/StarkFinder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.backend
More file actions
91 lines (78 loc) · 2.64 KB
/
Dockerfile.backend
File metadata and controls
91 lines (78 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
FROM node:20-slim AS builder
WORKDIR /app
# Next seems to analyze API routes at build time
# https://github.com/Shonen-Labs/StarkFinder/blob/0c1c7072cc9df592eac8050ee944a6d1ae4f21e8/client/app/api/transactions/route.ts#L26
# Should:
# 1. Move API client instantiation inside of handler functions
# 2. Make sure all secret usages are inside handler/request functions or lazy functions
# interim fix add ******* -> compose will override these with env vars
ENV OPENAI_API_KEY=*******
ENV BRIAN_API_KEY=*******
ENV ANTHROPIC_API_KEY=*******
ENV BRIAN_API_KEY=*******
ENV DEFAULT_LLM_PROVIDER=*******
ENV STARKNET_RPC_URL=*******
ENV ACCOUNT_ADDRESS=*******
ENV OZ_ACCOUNT_PRIVATE_KEY=*******
ENV DATABASE_URL=*******
#minimal package.json
RUN cat <<EOF > package.json
{
"name": "api-backend",
"version": "1.0.0",
"scripts": {
"build": "prisma generate && next build",
"start": "next start"
},
"dependencies": {
"@prisma/client": "^6.3.1",
"@anthropic-ai/sdk": "^0.39.0",
"@langchain/openai": "^0.3.17",
"@langchain/core": "^0.3.31",
"@langchain/anthropic": "^0.3.11",
"@langchain/langgraph": "^0.2.41",
"axios": "^1.7.9",
"prisma": "^6.3.1",
"starknet": "^6.11.0",
"next": "14.2.17",
"@next/mdx": "^15.3.2",
"typescript": "^5.8.3"
}
}
EOF
RUN npm install
# Copy sources needed for build
COPY ./client/app/api ./app/api
COPY ./client/tsconfig.json ./
COPY ./client/next.config.mjs ./
COPY ./client/prisma ./prisma
COPY ./client/lib ./lib
COPY ./client/components.json ./
COPY ./client/webpack.config.js ./
COPY ./client/prompts ./prompts
RUN npm run build
# ---- Production Image ----
FROM node:20-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
# Install wget for healthcheck
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
# Copy only the built app and deps
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
COPY --from=builder /app/next.config.mjs ./
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/lib ./lib
COPY --from=builder /app/app/api ./app/api
COPY --from=builder /app/components.json ./
COPY --from=builder /app/webpack.config.js ./
COPY --from=builder /app/prompts ./prompts
# Prisma (required for runtime queries)
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
#copy schema.prisma for runtime
COPY --from=builder /app/prisma/schema.prisma ./prisma/schema.prisma
EXPOSE 3000
# healthcheck
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
CMD ["npm", "start"]