-
Notifications
You must be signed in to change notification settings - Fork 478
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (59 loc) · 2.94 KB
/
Copy pathDockerfile
File metadata and controls
71 lines (59 loc) · 2.94 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
# syntax=docker/dockerfile:1.7
#
# Squad container image — built from a standalone bundle, no npm at runtime.
#
# Honors the environment-variable and path contract documented in
# docs/src/content/docs/reference/container-image.md (WORKDIR /app, non-root
# uid 1001, SIGTERM drain, `squad watch --execute` as the default command).
#
# The difference from the reference Dockerfile in that page is where the CLI
# comes from: instead of `npm install -g @bradygaster/squad-cli` at image build
# time, this copies a self-contained bundle produced by
# scripts/build-standalone.mjs. npm is used only inside the builder stage, so
# the final image has no dependency on registry.npmjs.org — matching the goal
# of #1593 and the limitation deferred in #1587.
#
# Build:
# docker build -t squad:local .
#
# Run:
# docker run --rm -e GITHUB_TOKEN=... -v "$PWD/.squad:/app/.squad" squad:local
# ---------------------------------------------------------------- builder ---
FROM node:22-alpine AS builder
WORKDIR /build
# The root package.json declares a workspace with a `file:` dependency on
# packages/squad-sdk, so a manifest-only cache layer cannot resolve — copy the
# source first, then install.
COPY . .
RUN npm ci --no-audit --no-fund
# --skip-runtime: the runtime stage is already a Node image, so vendoring a
# second Node would only add weight — and the official nodejs.org builds are
# glibc, which would not run on this musl base anyway.
# --include-optional: the container genuinely needs the optional dependencies.
# `squad watch --execute` spawns the Copilot CLI, and the container contract
# documents OTLP export, which lives in the optional OpenTelemetry packages.
RUN npm run build \
&& node scripts/build-standalone.mjs \
--platform linux --arch x64 \
--skip-runtime --include-optional \
--out-dir /out
# ---------------------------------------------------------------- runtime ---
FROM node:22-alpine AS runtime
# Non-root user (UID 1001 avoids common conflicts with bind mounts).
RUN addgroup --system squad && adduser --system --ingroup squad --uid 1001 squad
WORKDIR /app
# The bundle: launcher + app/node_modules (squad-cli, squad-sdk, templates,
# presets, and the Copilot CLI platform binary).
COPY --from=builder --chown=squad:squad /out/squad-linux-x64 /opt/squad
# `squad` on PATH, plus the bundled Copilot CLI that `squad watch` spawns.
ENV PATH="/opt/squad:/opt/squad/app/node_modules/.bin:${PATH}"
# Tells the CLI it is running from a bundle, so `squad init` writes a
# squad_state MCP spec that points at this launcher instead of npx — which
# would be unrunnable in an image with no npm registry access (#1593).
ENV SQUAD_STANDALONE_HOME=/opt/squad
USER squad
# Squad handles SIGTERM: drains in-flight work, then exits cleanly.
STOPSIGNAL SIGTERM
# GITHUB_TOKEN must be provided at runtime — never bake it into the image.
# Inject via Kubernetes Secret, ACA Key Vault reference, or CSI driver.
CMD ["squad", "watch", "--execute"]