DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to bake Laya weights into a container image at build time with Laya

Fetch the 1.7 GB ONNX bundle during the image build so containers start without a download.

Short answer: Add npm install @receptron/laya to the image build; then add node -e 'import("@receptron/laya").then((m) => m.ensureBundle())' as a build step so the weights are cached; set LAYA_CACHE to a path that the runtime user can read if you want the cache in a fixed location. All steps.

Who it is forA DevOps engineer deploying a Node.js service that uses Laya and needs fast, predictable container start-up.

The problemThe first Laya.load() downloads about 1.7 GB, which can stall or fail a container health check at start-up.

The outcomeA build step caches the weights, so a running container loads the model from the local cache and only sends a cheap freshness check.

What you need first

  • Node.js 20 or newer
  • About 2 GB of RAM for the loaded model, plus a few hundred MB per batch of questions
  • About 1.7 GB of free disk space for the ONNX weights cached under ~/.cache/receptron-laya
  • Network access to Hugging Face for the first download

Steps

  1. Add npm install @receptron/laya to the image build.
  2. Add node -e 'import("@receptron/laya").then((m) => m.ensureBundle())' as a build step so the weights are cached.
  3. Set LAYA_CACHE to a path that the runtime user can read if you want the cache in a fixed location.
  4. Pass revision with a commit hash to Laya.load() to pin the model version for reproducible results.
  5. Start the service and time the first Laya.load() call to confirm it reads from the cache.

Prompt for your agent

In the receptron/laya repo, write a Dockerfile for a Node.js 20 service at <service-dir> that installs @receptron/laya and runs ensureBundle() during the build. Expected output: an image where the first Laya.load() in the container finishes without a network download. Verify by running the container with networking disabled and confirming that the model loads.

Caveat. The README says the weights are about 1.7 GB in fp32 and the model needs roughly 2 GB of RAM, so size the container memory limit above that before deploying.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for receptron/laya and "Bake Laya weights into a container image at build time"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer