Skip to content

Commit d8f6bce

Browse files
authored
build: update planner build for sqlite3 (#12228)
refs: https://github.com/Agoric/agoric-private/issues/504 ## Description Updates the build scripts for ymax-planner in order to add some files that the new sqlite3 kv-store requires. Without this the planner crashes because the `better-sqlite3` package does not find the files it expects ### better-sqlite3 requirements - bindings file: a build file that is created by better-sqlite3 and needed independent of the final `entrypoint.js` build - node_modules: better-sqlite3 requires package.json/node_modules to identify the root directory of the package. ### build scripts the build script is also updated since we need to mount a directory for sqlite db in order to make it persistent across restarts ### Testing Considerations tested out by running test containers on GCP generated image: https://github.com/agoric/agoric-sdk/pkgs/container/agoric-sdk/577293600?tag=ymax-planner-test ### Upgrade Considerations The build scripts have been updated in the this PR and ymax planner must not be deployed without it
2 parents 399c890 + c188fb3 commit d8f6bce

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.github/scripts/deploy_vm.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ echo "Deploying to $GCE_INSTANCE: $IMAGE"
1717
gcloud compute instances update-container "$GCE_INSTANCE" \
1818
--zone "$GCE_ZONE" \
1919
--container-env-file "$ENV_FILE" \
20-
--container-image "$IMAGE"
20+
--container-image "$IMAGE" \
21+
--container-mount-host-path=mount-path=/db_data,host-path=/var/lib/kv-store,mode=rw

services/ymax-planner/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ RUN --mount=type=cache,target=/root/.yarn/berry/cache yarn install --mode=skip-b
2828
RUN cd packages/cosmic-proto && yarn build
2929
RUN cd packages/client-utils && yarn build
3030
RUN cd services/ymax-planner && yarn build
31+
# `yarn workspaces focus ... --production` builds better-sqlite3 bindings without triggering build
32+
# of dependencies such as xsnap.
33+
RUN yarn workspaces focus @aglocal/ymax-planner --production
3134
RUN cd packages/portfolio-contract && yarn build
3235

3336
# Production stage
@@ -42,6 +45,18 @@ LABEL org.opencontainers.image.title="ymax-planner" \
4245
# Copy built application from builder stage
4346
COPY --from=builder /build/services/ymax-planner/dist/entrypoint.js /app/entrypoint.js
4447

48+
# Copy better-sqlite3 bindings
49+
# better-sqlite3 will not run without this bindings file
50+
COPY --from=builder /build/node_modules/better-sqlite3/build/Release /app/Release
51+
52+
# Copy node_modules for better-sqlite3
53+
#
54+
# better-sqlite3 requires that a node_modules or packages.json file be present
55+
# in order to find a root directory. since we use a compressed bundle, those
56+
# folders arent present and must be manually added
57+
RUN mkdir /app/node_modules
58+
COPY --from=builder /build/node_modules/better-sqlite3 /app/node_modules/better-sqlite3
59+
4560
# Copy built highs.wasm file from builder stage
4661
COPY --from=builder /build/node_modules/highs/build/highs.wasm /app/highs.wasm
4762

0 commit comments

Comments
 (0)