arcticaurora commited on
Commit
dcf3b75
·
verified ·
1 Parent(s): 559aac9

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +91 -0
Dockerfile ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # =======================
2
+ # Stage 1: Builder
3
+ # =======================
4
+ FROM ghcr.io/astral-sh/uv:debian AS builder
5
+
6
+ # Install Node.js, pnpm, git, and build essentials
7
+ RUN apt-get update && apt-get install -y \
8
+ curl \
9
+ gnupg \
10
+ git \
11
+ && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
12
+ && apt-get install -y nodejs \
13
+ && npm install -g pnpm@10.12.0 \
14
+ && apt-get clean \
15
+ && rm -rf /var/lib/apt/lists/*
16
+
17
+ WORKDIR /app
18
+
19
+ # Clone the MetaMCP repository
20
+ RUN git clone https://github.com/metatool-ai/metamcp.git .
21
+
22
+ # Install dependencies
23
+ RUN pnpm install --frozen-lockfile
24
+
25
+ # Build all packages and apps
26
+ RUN pnpm build
27
+
28
+ # Fix Next.js timeout (from original Dockerfile)
29
+ RUN sed -i -e "s/30000/600000/" \
30
+ "node_modules/.pnpm/next@15.5.2_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/server/lib/router-utils/proxy-request.js" \
31
+ "node_modules/.pnpm/next@15.5.2_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/next/dist/esm/server/lib/router-utils/proxy-request.js"
32
+
33
+ # =======================
34
+ # Stage 2: Runtime
35
+ # =======================
36
+ FROM ghcr.io/astral-sh/uv:debian
37
+
38
+ # Install Node.js, pnpm, and runtime dependencies
39
+ RUN apt-get update && apt-get install -y \
40
+ curl \
41
+ gnupg \
42
+ postgresql-client \
43
+ && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
44
+ && apt-get install -y nodejs \
45
+ && npm install -g pnpm@10.12.0 \
46
+ && apt-get clean \
47
+ && rm -rf /var/lib/apt/lists/*
48
+
49
+ # Create user with UID 1000 for HF Spaces
50
+ RUN useradd -m -u 1000 -s /bin/bash user && \
51
+ mkdir -p /home/user/.cache/node/corepack && \
52
+ chown -R user:user /home/user
53
+
54
+ WORKDIR /app
55
+
56
+ # Copy built application from builder
57
+ COPY --from=builder --chown=user:user /app/apps/frontend/.next ./apps/frontend/.next
58
+ COPY --from=builder --chown=user:user /app/apps/frontend/package.json ./apps/frontend/
59
+ COPY --from=builder --chown=user:user /app/apps/backend/dist ./apps/backend/dist
60
+ COPY --from=builder --chown=user:user /app/apps/backend/package.json ./apps/backend/
61
+ COPY --from=builder --chown=user:user /app/apps/backend/drizzle ./apps/backend/drizzle
62
+ COPY --from=builder --chown=user:user /app/apps/backend/drizzle.config.ts ./apps/backend/
63
+
64
+ # Copy packages and dependencies
65
+ COPY --from=builder --chown=user:user /app/packages ./packages
66
+ COPY --from=builder --chown=user:user /app/node_modules ./node_modules
67
+ COPY --from=builder --chown=user:user /app/package.json ./
68
+ COPY --from=builder --chown=user:user /app/pnpm-workspace.yaml ./
69
+
70
+ # Install production dependencies
71
+ RUN pnpm install --prod
72
+
73
+ # Install drizzle-kit for migrations
74
+ RUN cd apps/backend && pnpm add drizzle-kit@0.31.1
75
+
76
+ # Copy the entrypoint script
77
+ COPY --from=builder --chown=user:user /app/docker-entrypoint.sh ./
78
+ RUN chmod +x docker-entrypoint.sh
79
+
80
+ # Switch to non-root user
81
+ USER user
82
+
83
+ # Expose port 12008 (Next.js frontend)
84
+ EXPOSE 12008
85
+
86
+ # Health check
87
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
88
+ CMD curl -f http://localhost:12008/health || exit 1
89
+
90
+ # Start both services using original entrypoint
91
+ CMD ["./docker-entrypoint.sh"]