Spaces:
Paused
Paused
File size: 2,542 Bytes
0ef30b8 | 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 | # Single-stage build with Node.js 24
FROM node:24-slim
WORKDIR /app
# Install system dependencies required for Playwright/Camoufox browser, VNC, and git
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
unzip \
git \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libatspi2.0-0 \
libcups2 \
libdbus-1-3 \
libdrm2 \
libgbm1 \
libgtk-3-0 \
libnspr4 \
libnss3 \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Clone the repository directly (replace with your actual repo URL)
RUN git clone --depth 1 https://github.com/iBUHub/AIStudioToAPI.git /tmp/repo \
&& cp -r /tmp/repo/* /tmp/repo/.[!.]* /app/ 2>/dev/null || true \
&& rm -rf /tmp/repo
# Copy package manifests and install all dependencies
COPY package*.json ./
RUN npm install --no-audit --no-fund --ignore-scripts \
&& npm cache clean --force
# Download and extract Camoufox browser binary
ARG CAMOUFOX_URL
RUN ARCH=$(uname -m) && \
if [ -z "$CAMOUFOX_URL" ]; then \
if [ "$ARCH" = "x86_64" ]; then \
CAMOUFOX_URL="https://github.com/daijro/camoufox/releases/download/v135.0.1-beta.24/camoufox-135.0.1-beta.24-lin.x86_64.zip"; \
elif [ "$ARCH" = "aarch64" ]; then \
CAMOUFOX_URL="https://github.com/daijro/camoufox/releases/download/v135.0.1-beta.24/camoufox-135.0.1-beta.24-lin.arm64.zip"; \
else \
echo "Unsupported architecture: $ARCH" && exit 1; \
fi; \
fi && \
mkdir -p camoufox-linux && \
curl -sSL ${CAMOUFOX_URL} -o camoufox.zip && \
unzip -q camoufox.zip -d /tmp/cf || true && \
if [ -f /tmp/cf/camoufox ]; then \
mv /tmp/cf/* camoufox-linux/; \
else \
mv /tmp/cf/*/* camoufox-linux/; \
fi && \
rm -rf /tmp/cf camoufox.zip && \
chmod +x /app/camoufox-linux/camoufox
# Build frontend assets with Vite
ARG VERSION
RUN VERSION=${VERSION} npm run build:ui || true
# Remove dev dependencies after build to reduce image size
RUN npm prune --omit=dev && npm cache clean --force
USER root
EXPOSE 7860
ENV NODE_ENV=production \
CAMOUFOX_EXECUTABLE_PATH=/app/camoufox-linux/camoufox
HEALTHCHECK --interval=60s --timeout=30s --start-period=120s --retries=5 \
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); });"
CMD ["node", "main.js"] |