-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (41 loc) · 1.38 KB
/
Dockerfile
File metadata and controls
54 lines (41 loc) · 1.38 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
FROM node:22-slim AS base
# Install git (needed for update checker) and build essentials (needed for better-sqlite3)
RUN apt-get update && apt-get install -y git python3 make g++ && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install dependencies
COPY package.json package-lock.json ./
COPY scripts/postinstall.mjs ./scripts/postinstall.mjs
RUN npm config set fetch-retries 5 \
&& npm config set fetch-retry-factor 2 \
&& npm config set fetch-retry-mintimeout 10000 \
&& npm config set fetch-retry-maxtimeout 120000 \
&& attempt=1 \
&& until npm ci; do \
if [ "$attempt" -ge 3 ]; then \
exit 1; \
fi; \
echo "npm ci failed on attempt ${attempt}; retrying..." >&2; \
sleep $((attempt * 5)); \
attempt=$((attempt + 1)); \
done
# Copy source
COPY . .
# Build
RUN SWARMCLAW_BUILD_MODE=1 npm run build:ci
# Production
FROM node:22-slim AS runner
RUN apt-get update && apt-get install -y git curl unzip && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=base /app/.next/standalone ./
COPY --from=base /app/.next/static ./.next/static
COPY --from=base /app/public ./public
COPY --from=base /app/node_modules ./node_modules
COPY --from=base /app/package.json ./
# Data directory (mount as volume for persistence)
RUN mkdir -p /app/data
ENV NODE_ENV=production
ENV PORT=3456
ENV HOSTNAME=0.0.0.0
EXPOSE 3456
EXPOSE 3457
CMD ["node", "server.js"]