vinzcyun commited on
Commit
12014a6
·
verified ·
1 Parent(s): ef6bced

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -12
Dockerfile CHANGED
@@ -1,22 +1,31 @@
1
  # ===== Build stage =====
2
  FROM node:20-bullseye AS builder
 
 
3
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
 
 
4
  RUN corepack enable && corepack prepare pnpm@9.0.0 --activate
5
 
6
  WORKDIR /app
7
- RUN git clone --depth=1 https://github.com/mendableai/firecrawl.git .
 
 
 
 
 
8
  RUN pnpm install --frozen-lockfile
9
 
10
- # Build services
11
  WORKDIR /app/apps/playwright-service
12
  RUN pnpm build
 
13
  WORKDIR /app/apps/api
14
  RUN pnpm build
15
 
16
- # ===== Runtime stage (HF Space) =====
17
  FROM node:20-bullseye
18
 
19
- # Chromium deps cho Playwright
20
  RUN apt-get update && apt-get install -y \
21
  wget gnupg ca-certificates fonts-liberation libasound2 \
22
  libatk1.0-0 libatk-bridge2.0-0 libatspi2.0-0 libcups2 libdbus-1-3 \
@@ -27,24 +36,21 @@ RUN apt-get update && apt-get install -y \
27
 
28
  ENV NODE_ENV=production
29
  WORKDIR /app
 
 
30
  COPY --from=builder /app /app
31
 
32
- # Cài chromium & deps cho Playwright
33
  RUN npx playwright install chromium && npx playwright install-deps
34
 
35
- # Script chạy 2 tiến trình, port lấy từ $PORT do HF cung cấp
36
- # (HF gán $PORT=app_port, mặc định 7860)
37
  RUN printf '#!/usr/bin/env bash\nset -e\n\
38
  export PORT=${PORT:-7860}\n\
39
  export HOST=${HOST:-0.0.0.0}\n\
40
- # Bạn set các ENV khác trong Space Settings: REDIS_URL, USE_DB_AUTHENTICATION, v.v.\n\
41
- # Quan trọng: API đọc PLAYWRIGHT_MICROSERVICE_URL. Playwright service dưới đây mặc định nghe :3000\n\
42
  export PLAYWRIGHT_MICROSERVICE_URL=${PLAYWRIGHT_MICROSERVICE_URL:-http://127.0.0.1:3000/html}\n\
43
- # Start playwright microservice (port 3000, internal)\n\
44
  node /app/apps/playwright-service/dist/index.js &\n\
45
- # Start API (nghe $PORT để HF router map)\n\
46
  node /app/apps/api/dist/main.js\n' > /app/run.sh && chmod +x /app/run.sh
47
 
48
- # Expose đúng với app_port (HF sẽ map tự động, nhưng để rõ ràng)
49
  EXPOSE 7860
50
  CMD ["/app/run.sh"]
 
1
  # ===== Build stage =====
2
  FROM node:20-bullseye AS builder
3
+
4
+ # Cần git để clone
5
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
6
+
7
+ # pnpm
8
  RUN corepack enable && corepack prepare pnpm@9.0.0 --activate
9
 
10
  WORKDIR /app
11
+
12
+ # Clone mã nguồn Firecrawl (pin theo default branch; có thể đổi sang tag/commit bằng ARG)
13
+ ARG FIRECRAWL_REPO=https://github.com/mendableai/firecrawl.git
14
+ RUN git clone --depth=1 ${FIRECRAWL_REPO} .
15
+
16
+ # Cài deps workspace và build 2 service
17
  RUN pnpm install --frozen-lockfile
18
 
 
19
  WORKDIR /app/apps/playwright-service
20
  RUN pnpm build
21
+
22
  WORKDIR /app/apps/api
23
  RUN pnpm build
24
 
25
+ # ===== Runtime stage =====
26
  FROM node:20-bullseye
27
 
28
+ # Chromium/Playwright deps (tối thiểu an toàn)
29
  RUN apt-get update && apt-get install -y \
30
  wget gnupg ca-certificates fonts-liberation libasound2 \
31
  libatk1.0-0 libatk-bridge2.0-0 libatspi2.0-0 libcups2 libdbus-1-3 \
 
36
 
37
  ENV NODE_ENV=production
38
  WORKDIR /app
39
+
40
+ # Copy toàn bộ repo đã build
41
  COPY --from=builder /app /app
42
 
43
+ # Cài browser cho Playwright
44
  RUN npx playwright install chromium && npx playwright install-deps
45
 
46
+ # Script chạy 2 tiến trình: playwright-service (3000) + api ($PORT)
 
47
  RUN printf '#!/usr/bin/env bash\nset -e\n\
48
  export PORT=${PORT:-7860}\n\
49
  export HOST=${HOST:-0.0.0.0}\n\
50
+ # Bạn tự set các ENV khác trong Space Settings: USE_DB_AUTHENTICATION, REDIS_URL, v.v.\n\
 
51
  export PLAYWRIGHT_MICROSERVICE_URL=${PLAYWRIGHT_MICROSERVICE_URL:-http://127.0.0.1:3000/html}\n\
 
52
  node /app/apps/playwright-service/dist/index.js &\n\
 
53
  node /app/apps/api/dist/main.js\n' > /app/run.sh && chmod +x /app/run.sh
54
 
 
55
  EXPOSE 7860
56
  CMD ["/app/run.sh"]