-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (43 loc) · 1.81 KB
/
Copy pathDockerfile
File metadata and controls
53 lines (43 loc) · 1.81 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
# syntax=docker/dockerfile:1
# Dockerfile for a Skybridge MCP server.
#
# Detects npm, yarn, or pnpm from the lockfile in your project.
# (For bun or deno, adapt the install/build/prune commands below.)
# Build stage: install deps, compile the app, then prune dev deps.
FROM node:24-slim AS build
WORKDIR /app
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
RUN --mount=type=cache,target=/root/.npm \
--mount=type=cache,target=/usr/local/share/.cache/yarn \
--mount=type=cache,target=/root/.local/share/pnpm/store \
if [ -f package-lock.json ]; then \
npm ci; \
elif [ -f yarn.lock ]; then \
corepack enable yarn && yarn install --frozen-lockfile; \
elif [ -f pnpm-lock.yaml ]; then \
corepack enable pnpm && pnpm install --frozen-lockfile; \
else \
echo "No lockfile found." && exit 1; \
fi
ENV NODE_ENV=production
COPY . .
RUN if [ -f package-lock.json ]; then \
npm run build && npm prune --omit=dev; \
elif [ -f yarn.lock ]; then \
corepack enable yarn && yarn build && yarn install --frozen-lockfile --production=true; \
elif [ -f pnpm-lock.yaml ]; then \
corepack enable pnpm && pnpm build && pnpm prune --prod; \
fi
# Runtime stage: copy built artifacts and prod deps, run as non-root.
FROM node:24-slim AS runtime
WORKDIR /app
ENV NODE_ENV=production
USER node
COPY --from=build --chown=node:node /app/node_modules ./node_modules
COPY --from=build --chown=node:node /app/dist ./dist
COPY --from=build --chown=node:node /app/package.json ./package.json
EXPOSE 3000
# Run the built server directly rather than via `npm start` / `skybridge start`.
# Each wrapper adds a process layer that can swallow SIGTERM, which makes
# graceful shutdowns time out on platforms like Cloud Run, Fly, and k8s.
CMD ["node", "dist/server.js"]