-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDockerfile.ci
More file actions
58 lines (49 loc) · 2.44 KB
/
Copy pathDockerfile.ci
File metadata and controls
58 lines (49 loc) · 2.44 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
# Debian (glibc), not alpine (musl): the @meshsdk/core-csl / whisky-evaluator
# WebAssembly modules don't resolve under musl during `next build`.
#
# Two stages:
# - `base` : deps + source. Used by the ci-runner service, which only runs
# tsx scripts and must NOT run `next build`.
# - `app` : base + a production `next build`. Used by the app service.
FROM node:22-slim AS base
# Install PostgreSQL client tools for readiness checks.
RUN apt-get update \
&& apt-get install -y --no-install-recommends postgresql-client \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# @meshsdk/core-csl loads as a native ESM module whose whisky-evaluator WASM
# exports node can only resolve with --experimental-wasm-modules. Both the app
# (`next build` + `next start`) and the ci-runner (tsx scripts that import the
# Mesh SDK) need it, so set it on the shared base stage.
ENV NODE_OPTIONS=--experimental-wasm-modules
# Install dependencies first for better layer caching.
COPY package.json package-lock.json* ./
COPY prisma ./prisma
COPY prisma.config.ts ./
RUN npm ci
# Copy full source for containerized CI runs.
COPY . .
# Pre-bundle the CI CLI scripts with esbuild and run them with plain node.
# tsx's esbuild loader can't defer whisky-evaluator's .wasm imports to node's
# native --experimental-wasm-modules handling, so `tsx bootstrap.ts` fails to
# load @meshsdk/core-csl. Bundling (resolving @/ aliases, externalizing
# node_modules) lets `node --experimental-wasm-modules` load the WASM natively.
RUN npx --yes esbuild@0.25.10 \
scripts/ci/cli/bootstrap.ts \
scripts/ci/cli/wallet-status.ts \
scripts/ci/cli/route-chain.ts \
--bundle --platform=node --format=esm --packages=external \
--alias:@=./src --outdir=.ci-dist --out-extension:.js=.mjs
EXPOSE 3000
# --- Application image: production build served with `next start` ---------------
FROM base AS app
# Build the production app so the smoke runs `next start` (not `next dev`) and
# exercises the same output Vercel deploys. `next dev` mis-resolves the
# @meshsdk/core-csl / whisky-evaluator WASM path at runtime, 500-ing tx routes.
# Connection URLs are only needed at runtime (compose overrides these); the
# dummy DATABASE_URL keeps build-time module evaluation of the pg adapter happy.
# (NODE_OPTIONS=--experimental-wasm-modules is inherited from the base stage.)
ENV SKIP_ENV_VALIDATION=true
ENV NEXT_TELEMETRY_DISABLED=1
ENV DATABASE_URL=postgresql://build:build@localhost:5432/build
RUN npm run build