Skip to content

Commit b9bb575

Browse files
committed
wip
1 parent fc11f74 commit b9bb575

File tree

4 files changed

+141
-12
lines changed

4 files changed

+141
-12
lines changed

.github/workflows/image-staging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
uses: docker/build-push-action@v2
3434
with:
3535
context: .
36-
file: ./Dockerfile
36+
file: ./Dockerfile.service
3737
push: true
3838
tags: ghcr.io/firecrawl/firecrawl-mcp-server-alpha:latest
3939
cache-from: type=registry,ref=ghcr.io/firecrawl/firecrawl-mcp-server-alpha:latest

Dockerfile.service

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
1-
FROM node:22-slim
1+
## Service image: Node (FastMCP) + NGINX sidecar in one container
22

3+
# 1) Build stage
4+
FROM node:22-alpine AS builder
35
WORKDIR /app
46

5-
COPY package.json package-lock.json* ./
7+
COPY package*.json ./
8+
# Ensure dev dependencies (typescript, etc.) are installed for build
9+
RUN npm ci --include=dev
610

7-
8-
COPY tsconfig.json ./
9-
COPY src ./src
11+
COPY . .
1012
RUN npm run build
1113

12-
ENV CLOUD_SERVICE=true
13-
ENV PORT=3000
1414

15-
# Expose the port
16-
EXPOSE 3000
15+
# 2) Runtime stage (Node + NGINX)
16+
FROM node:22-alpine AS runner
17+
WORKDIR /app
18+
19+
RUN apk add --no-cache nginx bash curl
20+
21+
# Copy built app and install prod deps only
22+
COPY --from=builder /app/dist ./dist
23+
COPY package*.json ./
24+
RUN npm ci --omit=dev --ignore-scripts
25+
26+
# NGINX config and entrypoint
27+
COPY docker/nginx.conf /etc/nginx/nginx.conf
28+
COPY docker/entrypoint.sh /entrypoint.sh
29+
RUN chmod +x /entrypoint.sh
30+
31+
ENV PORT=3000
32+
EXPOSE 8080
1733

18-
# Run the server
19-
CMD ["node", "dist/index.js"]
34+
CMD ["/entrypoint.sh"]

docker/entrypoint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env sh
2+
set -e
3+
4+
# Start Node app in background
5+
node dist/index.js &
6+
APP_PID=$!
7+
8+
# Start NGINX in foreground
9+
nginx -g 'daemon off;'
10+
11+
wait $APP_PID
12+
13+

docker/nginx.conf

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
events {}
2+
http {
3+
upstream app { server 127.0.0.1:3000; }
4+
5+
server {
6+
listen 8080;
7+
8+
# Alias common typo/variant: /{apiKey}/v1|v2/see -> /sse
9+
location ~ ^/(?<apikey>[^/]+)/v(?:1|2)/see$ {
10+
proxy_set_header X-Firecrawl-API-Key $apikey;
11+
proxy_set_header Host $host;
12+
13+
proxy_buffering off;
14+
proxy_read_timeout 620s;
15+
proxy_send_timeout 620s;
16+
17+
proxy_pass http://app/sse;
18+
}
19+
20+
# Legacy with API key and version: /{apiKey}/v1|v2/{rest}
21+
location ~ ^/(?<apikey>[^/]+)/v(?:1|2)/(.*)$ {
22+
proxy_set_header X-Firecrawl-API-Key $apikey;
23+
proxy_set_header Host $host;
24+
25+
proxy_buffering off;
26+
proxy_read_timeout 620s;
27+
proxy_send_timeout 620s;
28+
29+
proxy_pass http://app/$2;
30+
}
31+
32+
# Legacy: /{apiKey}/{rest}
33+
location ~ ^/(?<apikey>[^/]+)/(.*)$ {
34+
proxy_set_header X-Firecrawl-API-Key $apikey;
35+
proxy_set_header Host $host;
36+
37+
proxy_buffering off;
38+
proxy_read_timeout 620s;
39+
proxy_send_timeout 620s;
40+
41+
proxy_pass http://app/$2;
42+
}
43+
44+
# Header-based with version alias: /v1|v2/see -> /sse
45+
location ~ ^/v(?:1|2)/see$ {
46+
proxy_buffering off;
47+
proxy_read_timeout 620s;
48+
proxy_send_timeout 620s;
49+
proxy_set_header Host $host;
50+
proxy_set_header X-Forwarded-For $remote_addr;
51+
proxy_set_header X-Forwarded-Proto $scheme;
52+
proxy_pass http://app/sse;
53+
}
54+
55+
# Header-based with version: /v1|v2/{rest}
56+
location ~ ^/v(?:1|2)/(.*)$ {
57+
proxy_buffering off;
58+
proxy_read_timeout 620s;
59+
proxy_send_timeout 620s;
60+
proxy_set_header Host $host;
61+
proxy_set_header X-Forwarded-For $remote_addr;
62+
proxy_set_header X-Forwarded-Proto $scheme;
63+
proxy_pass http://app/$1;
64+
}
65+
66+
# Direct header-based paths
67+
location /mcp {
68+
proxy_buffering off;
69+
proxy_read_timeout 620s;
70+
proxy_send_timeout 620s;
71+
proxy_pass http://app/mcp;
72+
proxy_set_header Host $host;
73+
proxy_set_header X-Forwarded-For $remote_addr;
74+
proxy_set_header X-Forwarded-Proto $scheme;
75+
}
76+
77+
location /messages {
78+
proxy_buffering off;
79+
proxy_read_timeout 620s;
80+
proxy_send_timeout 620s;
81+
proxy_pass http://app/messages;
82+
proxy_set_header Host $host;
83+
proxy_set_header X-Forwarded-For $remote_addr;
84+
proxy_set_header X-Forwarded-Proto $scheme;
85+
}
86+
87+
location /sse {
88+
proxy_buffering off;
89+
proxy_read_timeout 620s;
90+
proxy_send_timeout 620s;
91+
proxy_pass http://app/sse;
92+
proxy_set_header Host $host;
93+
proxy_set_header X-Forwarded-For $remote_addr;
94+
proxy_set_header X-Forwarded-Proto $scheme;
95+
}
96+
97+
location /health { return 200 "ok"; }
98+
}
99+
}
100+
101+

0 commit comments

Comments
 (0)