1
- # Build stage
1
+ # Use Node.js 23.3.0 as specified in package.json
2
2
FROM node:23.3.0-slim AS builder
3
3
4
4
# Playwright environment variables
@@ -7,11 +7,10 @@ ENV PLAYWRIGHT_BROWSERS_PATH=/usr/bin \
7
7
PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium \
8
8
PLAYWRIGHT_SKIP_BROWSER_VALIDATION=1
9
9
10
- # Install pnpm and build dependencies in a single layer
10
+ # Install pnpm globally and install necessary build tools
11
11
RUN npm install -g pnpm@9.4.0 && \
12
12
apt-get update && \
13
- apt-get install -y --no-install-recommends \
14
- git python3 make g++ curl \
13
+ apt-get install -y git python3 make g++ curl \
15
14
chromium \
16
15
dbus \
17
16
libglib2.0-0 \
@@ -33,28 +32,28 @@ RUN npm install -g pnpm@9.4.0 && \
33
32
libasound2 \
34
33
libatspi2.0-0 && \
35
34
apt-get clean && \
36
- rm -rf /var/lib/apt/lists/* && \
37
- # Set up D-Bus configuration
38
- mkdir -p /var/run/dbus && \
35
+ rm -rf /var/lib/apt/lists/*
36
+
37
+ # Set up D-Bus configuration
38
+ RUN mkdir -p /var/run/dbus && \
39
39
dbus-uuidgen > /var/lib/dbus/machine-id && \
40
- mkdir -p /usr/share/dbus-1/services && \
41
- # Create D-Bus service file for Chrome Session Manager
42
- echo "[D-BUS Service]\
40
+ mkdir -p /usr/share/dbus-1/services
41
+
42
+ # Create D-Bus service file for Chrome Session Manager
43
+ RUN echo "[D-BUS Service]\
43
44
Name=org.chromium.SessionManager\
44
45
Exec=/usr/bin/chromium --no-sandbox\
45
- User=root" > /usr/share/dbus-1/services/org.chromium.SessionManager.service && \
46
- # Set Python 3 as the default python
47
- ln -s /usr/bin/python3 /usr/bin/python
46
+ User=root" > /usr/share/dbus-1/services/org.chromium.SessionManager.service
47
+
48
+ # Set Python 3 as the default python
49
+ RUN ln -s /usr/bin/python3 /usr/bin/python
48
50
49
51
WORKDIR /app
50
52
51
- # Copy package files first to leverage Docker cache
52
- COPY package.json pnpm-workspace.yaml .npmrc turbo.json ./
53
- COPY agent/package.json ./agent/
54
- COPY client/package.json ./client/
55
- COPY packages/*/package.json ./packages/
53
+ # Copy all files
54
+ COPY . .
56
55
57
- # Install dependencies with improved caching
56
+ # Install dependencies with improved error handling and debugging
58
57
RUN pnpm install --frozen-lockfile || \
59
58
(echo "Frozen lockfile install failed, trying without..." && \
60
59
pnpm install --no-frozen-lockfile) && \
@@ -63,24 +62,27 @@ RUN pnpm install --frozen-lockfile || \
63
62
# Debug workspace packages
64
63
pnpm list -r | grep "@elizaos" || echo "No workspace packages found!"
65
64
66
- # Copy the rest of the files after dependency installation
67
- COPY . .
68
-
69
- # Build with detailed logging but cleaner approach
65
+ # Build with detailed logging
70
66
RUN set -ex && \
71
67
for i in 1 2 3; do \
72
68
echo "Build attempt $i" && \
73
- (PNPM_DEBUG=1 DEBUG=* TURBO_LOG_VERBOSITY=verbose pnpm build-docker 2>&1) && break || \
74
- (echo "Build failed, retrying..." && \
69
+ (PNPM_DEBUG=1 DEBUG=* TURBO_LOG_VERBOSITY=verbose pnpm build-docker 2>&1 | tee build_attempt_${i}.log) && exit 0 || \
70
+ (echo "=== Build Failure Details for Attempt ${i} ===" && \
71
+ cat build_attempt_${i}.log && \
72
+ echo "=== End of Build Failure Details ===" && \
73
+ echo "Build failed, retrying..." && \
75
74
sleep 5) \
76
75
done && \
77
- # Prune for production
78
- pnpm prune --prod && \
79
- echo "Production pruning completed" && \
80
- # Remove build logs to reduce image size
81
- rm -rf build_attempt_*.log || true
76
+ echo "All build attempts failed" && \
77
+ echo "=== All Build Logs ===" && \
78
+ cat build_attempt_*.log && \
79
+ exit 1
80
+
81
+ # Prune for production
82
+ RUN pnpm prune --prod && \
83
+ echo "Production pruning completed"
82
84
83
- # Runtime stage
85
+ # Final stage
84
86
FROM node:23.3.0-slim
85
87
86
88
# Playwright environment variables
@@ -89,7 +91,7 @@ ENV PLAYWRIGHT_BROWSERS_PATH=/usr/bin \
89
91
PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium \
90
92
PLAYWRIGHT_SKIP_BROWSER_VALIDATION=1
91
93
92
- # Install runtime dependencies in a single layer
94
+ # Install runtime dependencies and certificates first
93
95
RUN apt-get update && \
94
96
apt-get upgrade -y && \
95
97
apt-get install -y --no-install-recommends \
@@ -138,23 +140,26 @@ RUN apt-get update && \
138
140
libcairo2 \
139
141
libasound2 \
140
142
libatspi2.0-0 && \
141
- # Install Google Cloud SDK in same layer
143
+ apt-get clean && \
144
+ rm -rf /var/lib/apt/lists/*
145
+
146
+ # Install pnpm, PM2, and Google Cloud SDK
147
+ RUN npm install -g pnpm@9.4.0 pm2@latest && \
148
+ apt-get update && \
149
+ apt-get install -y git python3 curl gnupg && \
142
150
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \
143
151
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && \
144
152
apt-get update && \
145
153
apt-get install -y google-cloud-sdk && \
146
- # Install pnpm and PM2
147
- npm install -g pnpm@9.4.0 pm2@latest && \
148
- # Clean up
149
154
apt-get clean && \
150
- rm -rf /var/lib/apt/lists/* && \
151
- # Set up directories
152
- mkdir -p /app/logs && \
155
+ rm -rf /var/lib/apt/lists/*
156
+
157
+ RUN mkdir -p /app/logs && \
153
158
chmod 755 /app/logs
154
159
155
160
WORKDIR /app
156
161
157
- # Copy only necessary files from builder
162
+ # Copy necessary files from builder
158
163
COPY --from=builder /app/package.json ./
159
164
COPY --from=builder /app/pnpm-workspace.yaml ./
160
165
COPY --from=builder /app/.npmrc ./
@@ -183,11 +188,7 @@ RUN service cron start
183
188
EXPOSE 3000 5173
184
189
185
190
# CMD that fetches and runs the entrypoint script
186
- CMD sh -c 'if [ ! -f /run/dbus/pid ] || ! ps -p $(cat /run/dbus/pid) > /dev/null; then \
187
- rm -f /run/dbus/pid; \
188
- dbus-daemon --system --fork; \
189
- fi && \
190
- echo "Fetching latest container entrypoint script..." && \
191
- gsutil cp "gs://${AGENTS_BUCKET_NAME}/_project-files/container-entrypoint.sh" /app/container-entrypoint.sh && \
192
- chmod +x /app/container-entrypoint.sh && \
193
- /app/container-entrypoint.sh'
191
+ CMD dbus-daemon --system --fork && sh -c 'echo "Fetching latest container entrypoint script..." && \
192
+ gsutil cp "gs://${AGENTS_BUCKET_NAME}/_project-files/container-entrypoint.sh" /app/container-entrypoint.sh && \
193
+ chmod +x /app/container-entrypoint.sh && \
194
+ /app/container-entrypoint.sh'
0 commit comments