xhserver commited on
Commit
0ef30b8
·
verified ·
1 Parent(s): c4dbbc2

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +76 -0
Dockerfile ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Single-stage build with Node.js 24
2
+ FROM node:24-slim
3
+
4
+ WORKDIR /app
5
+
6
+ # Install system dependencies required for Playwright/Camoufox browser, VNC, and git
7
+ RUN apt-get update && apt-get install -y --no-install-recommends \
8
+ ca-certificates \
9
+ curl \
10
+ unzip \
11
+ git \
12
+ libasound2 \
13
+ libatk-bridge2.0-0 \
14
+ libatk1.0-0 \
15
+ libatspi2.0-0 \
16
+ libcups2 \
17
+ libdbus-1-3 \
18
+ libdrm2 \
19
+ libgbm1 \
20
+ libgtk-3-0 \
21
+ libnspr4 \
22
+ libnss3 \
23
+ && rm -rf /var/lib/apt/lists/* \
24
+ && apt-get clean
25
+
26
+ # Clone the repository directly (replace with your actual repo URL)
27
+ RUN git clone --depth 1 https://github.com/iBUHub/AIStudioToAPI.git /tmp/repo \
28
+ && cp -r /tmp/repo/* /tmp/repo/.[!.]* /app/ 2>/dev/null || true \
29
+ && rm -rf /tmp/repo
30
+
31
+ # Copy package manifests and install all dependencies
32
+ COPY package*.json ./
33
+ RUN npm install --no-audit --no-fund --ignore-scripts \
34
+ && npm cache clean --force
35
+
36
+ # Download and extract Camoufox browser binary
37
+ ARG CAMOUFOX_URL
38
+ RUN ARCH=$(uname -m) && \
39
+ if [ -z "$CAMOUFOX_URL" ]; then \
40
+ if [ "$ARCH" = "x86_64" ]; then \
41
+ CAMOUFOX_URL="https://github.com/daijro/camoufox/releases/download/v135.0.1-beta.24/camoufox-135.0.1-beta.24-lin.x86_64.zip"; \
42
+ elif [ "$ARCH" = "aarch64" ]; then \
43
+ CAMOUFOX_URL="https://github.com/daijro/camoufox/releases/download/v135.0.1-beta.24/camoufox-135.0.1-beta.24-lin.arm64.zip"; \
44
+ else \
45
+ echo "Unsupported architecture: $ARCH" && exit 1; \
46
+ fi; \
47
+ fi && \
48
+ mkdir -p camoufox-linux && \
49
+ curl -sSL ${CAMOUFOX_URL} -o camoufox.zip && \
50
+ unzip -q camoufox.zip -d /tmp/cf || true && \
51
+ if [ -f /tmp/cf/camoufox ]; then \
52
+ mv /tmp/cf/* camoufox-linux/; \
53
+ else \
54
+ mv /tmp/cf/*/* camoufox-linux/; \
55
+ fi && \
56
+ rm -rf /tmp/cf camoufox.zip && \
57
+ chmod +x /app/camoufox-linux/camoufox
58
+
59
+ # Build frontend assets with Vite
60
+ ARG VERSION
61
+ RUN VERSION=${VERSION} npm run build:ui || true
62
+
63
+ # Remove dev dependencies after build to reduce image size
64
+ RUN npm prune --omit=dev && npm cache clean --force
65
+
66
+ USER root
67
+
68
+ EXPOSE 7860
69
+
70
+ ENV NODE_ENV=production \
71
+ CAMOUFOX_EXECUTABLE_PATH=/app/camoufox-linux/camoufox
72
+
73
+ HEALTHCHECK --interval=60s --timeout=30s --start-period=120s --retries=5 \
74
+ CMD node -e "const http = require('http'); const req = http.get('http://localhost:7860/', (res) => { process.exit(res.statusCode === 200 || res.statusCode === 404 ? 0 : 1); }); req.on('error', () => process.exit(1)); req.setTimeout(10000, () => { req.destroy(); process.exit(1); });"
75
+
76
+ CMD ["node", "main.js"]