-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathDockerfile
More file actions
101 lines (89 loc) · 3.18 KB
/
Dockerfile
File metadata and controls
101 lines (89 loc) · 3.18 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Single-stage build with Node.js 24
FROM node:24-slim
WORKDIR /app
# Install system dependencies required for Playwright/Camoufox browser, VNC, and dev tools (git)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
unzip \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libatspi2.0-0 \
libcups2 \
libdbus-1-3 \
libdrm2 \
libgbm1 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxrandr2 \
libxss1 \
libxtst6 \
xvfb \
x11vnc \
websockify \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Copy package manifests and install all dependencies (including dev for build tools)
# Layer is cached unless package.json changes
COPY package*.json ./
RUN npm install --no-audit --no-fund --ignore-scripts \
&& npm cache clean --force
# Download and extract Camoufox browser binary
# Layer is cached unless CAMOUFOX_URL argument changes
# Automatically selects architecture-specific binary if URL not provided
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
# Copy application source code with proper ownership
# Layer is rebuilt when source code changes
COPY --chown=node:node main.js ./
COPY --chown=node:node vite.config.js ./
COPY --chown=node:node src ./src
COPY --chown=node:node configs ./configs
COPY --chown=node:node scripts ./scripts
COPY --chown=node:node ui ./ui
# Build frontend assets with Vite
# VERSION is passed from docker build-args for version display in UI
ARG VERSION
RUN VERSION=${VERSION} npm run build:ui
# Remove dev dependencies after build to reduce image size
RUN npm prune --omit=dev && npm cache clean --force
# TODO: Temporarily use the root user, and in the future we will switch to the node user
USER root
# Expose application ports
EXPOSE 7860
# Configure runtime environment
ENV NODE_ENV=production \
CAMOUFOX_EXECUTABLE_PATH=/app/camoufox-linux/camoufox
# Health check for container orchestration platforms
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD node -e "const port = process.env.PORT || 7860; require('http').get('http://localhost:' + port + '/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)}).on('error', () => process.exit(1));" || exit 1
# Start the application server
CMD ["node", "main.js"]