Repository navigation
Expand file tree
/
Copy pathDockerfile.server
More file actions
63 lines (60 loc) · 2.81 KB
/
Copy pathDockerfile.server
File metadata and controls
63 lines (60 loc) · 2.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
54
55
56
57
58
59
60
61
62
63
FROM node:24-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json tsconfig.base.json ./
COPY packages/shared/package.json packages/shared/
COPY packages/server/package.json packages/server/
RUN npm ci
COPY packages/shared packages/shared
COPY packages/server packages/server
RUN npm run build -w packages/shared
RUN npm run build -w packages/server
# The hosted recorder served at /session. Built in its own stage on purpose:
# the runtime image copies node_modules wholesale from `builder`, so keeping
# vite/tsup and the whole React toolchain out of that tree is the difference
# between shipping them and not. Only the built assets cross over.
# The recorder engine, compiled to WebAssembly (@lookout/wasm), which
# @lookout/react loads. Only lookout-web and the crates under it build here.
FROM rust:1-slim-bookworm AS wasm
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& rustup target add wasm32-unknown-unknown
WORKDIR /app
COPY crates/Cargo.lock crates/
COPY packages/wasm/install-bindgen.sh packages/wasm/
RUN packages/wasm/install-bindgen.sh /usr/local/bin
COPY crates crates
COPY packages/wasm/build.sh packages/wasm/
RUN bash packages/wasm/build.sh
FROM node:24-alpine AS recorder
WORKDIR /app
COPY package.json package-lock.json tsconfig.base.json ./
COPY packages/shared/package.json packages/shared/
COPY packages/wasm/package.json packages/wasm/
COPY clients/react/package.json clients/react/
COPY clients/hosted/package.json clients/hosted/
RUN npm ci
COPY --from=wasm /app/packages/wasm/dist packages/wasm/dist
COPY clients/react clients/react
COPY clients/hosted clients/hosted
# Consume shared as a built artifact rather than rebuilding it here. Its tsc
# build compiles its own *.test.ts, so it needs vitest — which nothing in
# this stage's dependency subset brings in. The builder stage above has
# already produced exactly the dist the recorder needs.
COPY --from=builder /app/packages/shared/dist packages/shared/dist
RUN npm run build -w clients/react
RUN npm run build -w clients/hosted
FROM node:24-alpine
WORKDIR /app
COPY --from=builder /app/packages/server/dist ./dist
COPY --from=builder /app/packages/server/public ./public
# Mounted where the SPA fallback looks for it (see packages/server/src/index.ts).
COPY --from=recorder /app/clients/hosted/dist ./public/session
COPY --from=builder /app/packages/server/package.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/packages/shared/dist ./node_modules/@lookout/shared/dist
COPY --from=builder /app/packages/shared/package.json ./node_modules/@lookout/shared/
COPY --from=builder /app/packages/server/drizzle ./drizzle
COPY --from=builder /app/packages/server/drizzle.config.ts ./
EXPOSE 3000
CMD sh -c "npx drizzle-kit migrate && node dist/index.js"