Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
326 lines (294 loc) · 17.5 KB
/
Copy pathDockerfile
File metadata and controls
326 lines (294 loc) · 17.5 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# Comma systems — one image and one `comma` umbrella release containing every
# subsystem. Each pod starts only the subset selected by `COMMA_SUBSYSTEMS`.
# The built-in Docker healthcheck below targets Salix; deployments that omit
# Salix must override it with the selected subsystem's health endpoint.
#
# Stage 1 builds the OTP release; stage 2 is the slim runtime. Build from the
# systems/ repository root:
#
# docker build -f systems/Dockerfile -t comma .
#
# See DEPLOYMENT.md for required environment and topology.
# ---- Cloud SQL Proxy builder -----------------------------------------------
# Build the official proxy v2.25.4 from its pinned release commit with a patched
# Go toolchain. This release contains the reviewed upstream dependency updates
# for gRPC 1.83.2 and golang.org/x/crypto 0.55.0. A build module raises
# golang.org/x/net to 0.62.0 for CVE-2026-78669 and CVE-2026-78661; v2.26.0
# still pins 0.59.0.
FROM golang:1.26.11-trixie AS cloud-sql-proxy-builder
ARG CLOUD_SQL_PROXY_VERSION=7905bdd628cd80cfb15714a7197f5bbd4a49d844
ARG CLOUD_SQL_PROXY_X_NET_VERSION=v0.62.0
WORKDIR /src/cloud-sql-proxy
RUN go mod init cloud-sql-proxy-build \
&& go get \
github.com/GoogleCloudPlatform/cloud-sql-proxy/v2@${CLOUD_SQL_PROXY_VERSION} \
golang.org/x/net@${CLOUD_SQL_PROXY_X_NET_VERSION} \
&& CGO_ENABLED=0 go build -trimpath -o /out/cloud-sql-proxy \
github.com/GoogleCloudPlatform/cloud-sql-proxy/v2
# ---- Subscription worker builder ------------------------------------------
FROM golang:1.26.11-trixie AS subscription-worker-builder
WORKDIR /src
COPY systems/account-proxy/go.mod systems/account-proxy/go.sum systems/account-proxy/bootstrap.sh ./
COPY systems/account-proxy/patches ./patches
RUN ./bootstrap.sh && go mod download
COPY systems/account-proxy/*.go ./
COPY systems/account-proxy/cmd ./cmd
RUN CGO_ENABLED=0 go build -trimpath -o /subscription_worker ./cmd/salix-account-proxy
# ---- Profiles NIF builder --------------------------------------------------
# The Profiles' logic Comma and its stations share (systems/profiles), as
# SalixAgent.Profiles.Native loads it. Only its sources are copied, so the
# layer is rebuilt when they change and not otherwise.
FROM rust:1.95.0-slim-trixie AS profiles-nif-builder
WORKDIR /src
COPY systems/profiles/Cargo.toml systems/profiles/sources.json profiles/
COPY systems/profiles/src profiles/src
COPY systems/profiles/nif/Cargo.toml systems/profiles/nif/Cargo.lock profiles/nif/
COPY systems/profiles/nif/src profiles/nif/src
RUN cargo build --release --locked --manifest-path profiles/nif/Cargo.toml \
&& cp profiles/nif/target/release/libcomma_profiles_nif.so /comma_profiles_nif.so
# ---- Agent VMM worker builder ----------------------------------------------
# One process per Salix node for the node's Agent VMM Host connections
# (SalixStore.AgentVMM.Worker). Only the worker ships: the test Host stays out
# of the image. The protos are compiled in the build script, without protoc.
FROM rust:1.95.0-slim-trixie AS salix-vmm-worker-builder
WORKDIR /src
COPY systems/gateway/salix-vmm-worker/Cargo.toml systems/gateway/salix-vmm-worker/Cargo.lock systems/gateway/salix-vmm-worker/build.rs ./
COPY systems/gateway/salix-vmm-worker/proto proto
COPY systems/gateway/salix-vmm-worker/src src
RUN cargo build --release --locked --bin salix_vmm_worker \
&& cp target/release/salix_vmm_worker /salix_vmm_worker
# ---- Tailcat gateway builder ----------------------------------------------
# One process per Salix node for outbound SSH over Tailcat
# (SalixAgent.Tailcat.Gateway). Only the gateway command ships; the test peer
# stays out of the image.
FROM golang:1.27.4-trixie AS tailcat-gateway-builder
WORKDIR /src
COPY systems/tailcat-gateway/go.mod systems/tailcat-gateway/go.sum ./
RUN go mod download
COPY systems/tailcat-gateway/*.go ./
COPY systems/tailcat-gateway/cmd/salix-tailcat-gateway ./cmd/salix-tailcat-gateway
RUN CGO_ENABLED=0 go build -trimpath -ldflags='-s -w' -o /tailcat_gateway ./cmd/salix-tailcat-gateway
# ---- Tailnet gateway builder -----------------------------------------------
# One process per Salix node for the tailnet nodes of the Agent Groups that
# node owns (SalixAgent.Tailnet.Gateway).
FROM golang:1.27.4-trixie AS tailnet-gateway-builder
WORKDIR /src
COPY systems/tailnet-gateway/go.mod systems/tailnet-gateway/go.sum ./
RUN go mod download
COPY systems/tailnet-gateway/*.go ./
COPY systems/tailnet-gateway/cmd/salix-tailnet-gateway ./cmd/salix-tailnet-gateway
RUN CGO_ENABLED=0 go build -trimpath -ldflags='-s -w' -o /tailnet_gateway ./cmd/salix-tailnet-gateway
# ---- spinfoam fetcher -------------------------------------------------------
# The userspace eBPF runtime behind Agent background Loops
# (docs/salix/task-dynamic-workflow.md). The prebuilt release pinned in
# systems/native/spinfoam/SPINFOAM_VERSION is downloaded and verified against
# the pinned SHA256SUMS; the Elixir stage bundles the binary into
# salix_agent's priv/ exactly like the subscription worker. The binary embeds
# its C compiler, so no toolchain is involved at any stage.
FROM debian:trixie-slim AS spinfoam-fetcher
RUN apt-get update -y && apt-get install -y --no-install-recommends ca-certificates curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY systems/native/spinfoam/SPINFOAM_VERSION systems/native/spinfoam/SHA256SUMS systems/native/spinfoam/fetch.sh ./native/spinfoam/
RUN ./native/spinfoam/fetch.sh OUT=/out/spinfoam
# The locked SILK v3 decoder (systems/runtime-images/runtime-dependencies.lock.json,
# the one the Cloud VM images build): audio.transcribe decodes WeChat and QQ
# voice messages with it, since ffmpeg has no SILK decoder.
FROM debian:trixie-slim AS silk-decoder-builder
RUN apt-get update -y && apt-get install -y --no-install-recommends \
ca-certificates curl gcc g++ jq make openssl \
&& rm -rf /var/lib/apt/lists/*
COPY systems/runtime-images/runtime-dependencies.lock.json /tmp/runtime-dependencies.lock.json
RUN set -eu; \
tarball="$(jq -er .silkV3Decoder.tarball /tmp/runtime-dependencies.lock.json)"; \
integrity="$(jq -er .silkV3Decoder.integrity /tmp/runtime-dependencies.lock.json)"; \
curl --fail --location --silent --show-error "${tarball}" --output /tmp/silk.tgz; \
printf '%s' "${integrity#sha512-}" | base64 --decode >/tmp/silk.expected; \
openssl dgst -sha512 -binary /tmp/silk.tgz | cmp /tmp/silk.expected -; \
mkdir /tmp/silk && tar -xzf /tmp/silk.tgz -C /tmp/silk --strip-components=1; \
make -C /tmp/silk/silk lib decoder; \
install -D -m 0755 /tmp/silk/silk/decoder /out/silk-v3-decoder
# ---- Stage 1: Elixir release builder -------------------------------------
# ---- BFT dashboard builder -------------------------------------------------
# The React dashboard (clients/apps/bft) builds into
# systems/apps/bridge_for_teams_web/priv/static/bft; Phoenix serves it
# same-origin. Only the app's workspace dependency graph is installed.
FROM node:24-trixie-slim AS bft-dashboard-builder
WORKDIR /src
RUN corepack enable
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
COPY patches ./patches
COPY website/package.json website/package.json
COPY observability/grafana/package.json observability/grafana/package.json
COPY clients ./clients
RUN pnpm install --frozen-lockfile --ignore-scripts --filter "@comma/bft..."
RUN pnpm --filter @comma/i18n compile && pnpm --filter @comma/bft build
FROM hexpm/elixir:1.20.1-erlang-29.0.2-debian-trixie-20260610-slim AS elixir-builder
ARG COMMA_LOCAL_RECOMMENDATION_MOCK=false
ENV MIX_ENV=prod \
LANG=C.UTF-8
RUN apt-get update -y && apt-get install -y --no-install-recommends \
build-essential git ca-certificates nodejs npm curl cmake pkg-config libuv1-dev libssl-dev \
libsodium-dev libopus-dev libsrtp2-dev \
&& rm -rf /var/lib/apt/lists/*
# ex_sctp builds a Rust NIF; use the same toolchain as CI.
ENV RUSTUP_HOME=/opt/rustup CARGO_HOME=/opt/cargo
ENV PATH="/opt/cargo/bin:${PATH}"
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup-init.sh \
&& sh /tmp/rustup-init.sh -y --no-modify-path --profile minimal --default-toolchain 1.96.0 \
&& rm /tmp/rustup-init.sh
WORKDIR /app
# Lean is a build dependency. The runtime image receives only the static NIF.
ENV ELAN_HOME=/opt/elan
ENV PATH="/opt/elan/bin:${PATH}"
COPY systems/native/verified_kernel/lean-toolchain /tmp/lean-toolchain
COPY systems/native/verified_kernel/scripts/install-toolchain.sh /tmp/install-lean-toolchain.sh
RUN bash /tmp/install-lean-toolchain.sh /tmp/lean-toolchain
RUN mix local.hex --force && mix local.rebar --force
# Delay the capability input until after the OS/toolchain layer so toggling a
# local-only compile feature does not invalidate package installation.
ENV COMMA_LOCAL_RECOMMENDATION_MOCK=${COMMA_LOCAL_RECOMMENDATION_MOCK}
# Dependency layer (cached on mix.lock + per-app mix.exs).
COPY systems/mix.exs systems/mix.lock ./
COPY systems/apps/alert_router/mix.exs apps/alert_router/
COPY systems/apps/comma/mix.exs apps/comma/
COPY systems/apps/comma_log/mix.exs apps/comma_log/
COPY systems/apps/product_analytics/mix.exs apps/product_analytics/
COPY systems/apps/comma_ssh/mix.exs apps/comma_ssh/
COPY systems/apps/comma_tui/mix.exs apps/comma_tui/
COPY systems/apps/systems_observability/mix.exs apps/systems_observability/
COPY systems/apps/systems_clock/mix.exs apps/systems_clock/
COPY systems/apps/systems_runtime/mix.exs apps/systems_runtime/
COPY systems/apps/billing_core/mix.exs apps/billing_core/
COPY systems/apps/billing_commerce/mix.exs apps/billing_commerce/
COPY systems/apps/billing_stripe/mix.exs apps/billing_stripe/
COPY systems/apps/billing_apple/mix.exs apps/billing_apple/
COPY systems/apps/comma_core/mix.exs apps/comma_core/
COPY systems/apps/comma_web/mix.exs apps/comma_web/
COPY systems/apps/salix_store/mix.exs apps/salix_store/
COPY systems/apps/salix_calendar/mix.exs apps/salix_calendar/
COPY systems/apps/salix_agent/mix.exs apps/salix_agent/
COPY systems/apps/salix_cluster/mix.exs apps/salix_cluster/
COPY systems/apps/salix_web/mix.exs apps/salix_web/
COPY systems/apps/salix_llm/mix.exs apps/salix_llm/
COPY systems/apps/salix_im/mix.exs apps/salix_im/
COPY systems/apps/salix_env/mix.exs apps/salix_env/
COPY systems/apps/salix_analytics/mix.exs apps/salix_analytics/
COPY systems/apps/salix_media/mix.exs apps/salix_media/
COPY systems/apps/salix_meet/mix.exs apps/salix_meet/
COPY systems/apps/salix_meet_native/mix.exs apps/salix_meet_native/
COPY systems/apps/salix_voice/mix.exs apps/salix_voice/
COPY systems/apps/salix_signal/mix.exs apps/salix_signal/
COPY systems/apps/salix_signal_proto/mix.exs apps/salix_signal_proto/
COPY systems/apps/salix_mcp/mix.exs apps/salix_mcp/
COPY systems/apps/bridge_for_teams_core/mix.exs apps/bridge_for_teams_core/
COPY systems/apps/bridge_for_teams_web/mix.exs apps/bridge_for_teams_web/
COPY systems/config/config.exs config/
# Compile-time inputs that umbrella apps read while compiling — must be present
# BEFORE deps.compile (umbrella apps compile as path deps there), not just
# before the later `mix compile`:
# * native/ — the verified kernel path dependency and the spinfoam fetch
# script (`apps/salix_agent`'s `:spinfoam` compiler is a no-op here
# because the fetch stage supplies the binary).
# * salix_signal_proto's Makefile and C sources — its libsodium NIF builds
# whenever the app compiles, including as an in-umbrella dependency.
# salix_signal's libopus NIF (call media) likewise.
COPY systems/native native
COPY systems/apps/salix_signal_proto/Makefile apps/salix_signal_proto/Makefile
COPY systems/apps/salix_signal_proto/c_src apps/salix_signal_proto/c_src
COPY systems/apps/salix_signal/Makefile apps/salix_signal/Makefile
COPY systems/apps/salix_signal/c_src apps/salix_signal/c_src
COPY systems/connector/mac-mini-provisioner-install.sh connector/mac-mini-provisioner-install.sh
COPY systems/runtime-images/runtime-dependencies.lock.json runtime-images/runtime-dependencies.lock.json
COPY systems/private private
# rustler_precompiled downloads prebuilt NIFs (mdex_native and others) from
# GitHub releases; the builder's cache keeps them between builds.
RUN --mount=type=cache,target=/root/.cache/rustler_precompiled,sharing=locked \
mix deps.get --only prod && mix deps.compile
# Source + release.
COPY systems/config config
COPY systems/apps apps
COPY --from=subscription-worker-builder /subscription_worker apps/salix_agent/priv/subscription_worker
COPY --from=tailcat-gateway-builder /tailcat_gateway apps/salix_agent/priv/tailcat_gateway
COPY --from=salix-vmm-worker-builder /salix_vmm_worker apps/salix_store/priv/salix_vmm_worker
COPY --from=tailnet-gateway-builder /tailnet_gateway apps/salix_agent/priv/tailnet_gateway
COPY --from=spinfoam-fetcher /out/spinfoam apps/salix_agent/priv/spinfoam
COPY --from=profiles-nif-builder /comma_profiles_nif.so apps/salix_agent/priv/native/comma_profiles_nif.so
# CommaWeb.RecommendationRuntime embeds the versioned recommendation template
# catalog at compile time. Keep the repository-level catalog as the SSOT and
# make that external resource available at the same absolute path produced by
# its source-tree-relative lookup inside this builder (`/resources/...`).
COPY resources/salix-system-files/recommendation-template-catalog.v1.json /resources/salix-system-files/recommendation-template-catalog.v1.json
# ProactiveWatch embeds the Skill's Loop program from the same resource root.
COPY resources/salix-system-files/skills/proactive/scripts/watch.c /resources/salix-system-files/skills/proactive/scripts/watch.c
COPY --from=bft-dashboard-builder /src/systems/apps/bridge_for_teams_web/priv/static/bft apps/bridge_for_teams_web/priv/static/bft
# Build the bridge_for_teams dashboard assets (standalone tailwind+esbuild Hex
# installers download their binaries here) into priv/static before the release,
# which bundles each app's priv/. Harmless when the subsystem isn't run.
# The builder's cache keeps the binaries, named by version, so a rebuild does
# not depend on GitHub release downloads.
RUN --mount=type=cache,target=/root/.cache/comma-mix-assets,sharing=locked \
mkdir -p _build \
&& find /root/.cache/comma-mix-assets -maxdepth 1 -type f -exec cp -p {} _build/ \; \
&& mix assets.setup \
&& cp -p _build/tailwind-* _build/esbuild-* /root/.cache/comma-mix-assets/ \
&& mix assets.deploy
COPY systems/rel rel
RUN mix compile && mix release comma
# ---- Stage 2: runtime ------------------------------------------------------
# MUST track the builder's Debian release. mdex_native ships a precompiled NIF
# that requires a newer glibc than bullseye provides, and OTP's crypto NIF must
# see the same OpenSSL ABI it linked against during release compilation.
FROM debian:trixie-slim AS runtime
# libssl3t64 provides libcrypto.so.3 (required by the crypto NIF — see above).
# Trixie ships OpenSSL 3.5, which gives `:crypto` ML-KEM.
# libsodium23 is the shared library behind the salix_signal_proto NIF.
# libopus0 is the shared library behind the salix_signal Opus NIF (call media)
# and the Membrane Opus NIFs; libsrtp2-1 is the one behind the ex_libsrtp NIF
# (salix_meet_native).
# spinfoam (Agent background Loops) embeds its own C compiler, so the
# runtime image carries no toolchain for it (DEPLOYMENT.md, "Background Loops").
# The upgrade brings the base image's own packages (apt, libc6, ...) up to the
# latest trixie-security fixes, which the base image tag can lag behind.
ARG RUNTIME_APT_REFRESH=local
RUN echo "${RUNTIME_APT_REFRESH}" >/dev/null \
&& apt-get update -y && apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
libstdc++6 libssl3t64 libsodium23 libopus0 libsrtp2-1 openssl libpcre2-8-0 ca-certificates curl ffmpeg libheif-examples libheif-plugin-libde265 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=cloud-sql-proxy-builder /out/cloud-sql-proxy /usr/local/bin/cloud-sql-proxy
COPY --from=silk-decoder-builder /out/silk-v3-decoder /usr/local/bin/silk-v3-decoder
# Non-root runtime identity. Keep the UID/GID explicit because the same image is
# also used by Kubernetes sidecars whose runAsNonRoot policy cannot validate a
# named USER before the container starts.
RUN groupadd --gid 10001 comma \
&& useradd --uid 10001 --gid 10001 --create-home --home-dir /opt/comma comma
WORKDIR /opt/comma
USER 10001:10001
COPY --from=elixir-builder --chown=comma /app/_build/prod/rel/comma ./
COPY --chown=comma resources/salix-system-files /etc/salix-system
ARG SALIX_APP_REVISION=unknown
ENV SALIX_APP_REVISION=${SALIX_APP_REVISION} \
ALERT_ROUTER_PORT=4300 \
SALIX_HTTP_PORT=4000 \
SALIX_TRANSFER_PORT=4400 \
BRIDGE_DASHBOARD_HTTP_PORT=4101 \
LANG=C.UTF-8
# Alert Router ingress, Salix HTTP/SSE, Salix transfer, BridgeForTeams
# dashboard, EPMD, BEAM distribution (pin a range in your orchestrator; see
# DEPLOYMENT.md).
EXPOSE 4300 4000 4400 4101 4369 7443 9100-9110
HEALTHCHECK --interval=15s --timeout=3s --start-period=20s \
CMD curl -sf http://127.0.0.1:${SALIX_HTTP_PORT}/health || exit 1
# `start` runs in the foreground. This image-level healthcheck targets Salix on
# `SALIX_HTTP_PORT`; non-Salix deployments must replace it. On Salix pods, the
# deployment pre-stop hook calls bin/comma rpc
# "SalixCluster.Drain.drain([])" before SIGTERM.
ENTRYPOINT ["bin/comma"]
CMD ["start"]
# Production releases carry the complete Agent VMM runtime bundle. Local
# compose targets the runtime stage above so ordinary backend development does
# not build browser and agent images that it cannot consume.
FROM runtime AS release
COPY --chown=comma systems/runtime-images/dist/manifest.json /opt/comma/runtime-images/manifest.json
COPY --chown=comma systems/install-artifacts/release-descriptor.json /opt/comma/install-artifacts/release-descriptor.json