¥99.90
One-time template price with installation and customization
One-click private deployment after purchase, details Live previewDeployment Guide
Community pet shop operations 1.2.0 (template slug
petshop). Shape: one container (apion 8080, also serving the SPA,/api/*,/docsand/config.js), SQLite by default (/app/data/sqlite.db), migrations applied on start. The upload package already contains production artifacts; the image never installs or builds.
1. Five-minute deploy
A. docker compose (recommended for self-hosting)
docker compose up -d --build
Open http://localhost:8080 and sign in as admin@example.com / Admin@123456 (you will be asked to change it).
docker-compose.yml already wires the port, volume and variables:
ports: "${PORT:-8080}:8080"(container listens on 8080; the host port can be overridden withPORT);environment.PORT: "8080",BIND_HOST: "0.0.0.0", healthcheck onhttp://localhost:8080/api/health(all three are 8080);volumes: petshop-data:/app/data(database and backups live here).
For production, at least override these:
JWT_SECRET="$(openssl rand -hex 32)" SUPER_ADMIN_PASSWORD='<a strong owner password>' docker compose up -d
B. docker run
docker build -t petshop:1.2.0 .
docker run -d --name petshop -p 8080:8080 \
-e JWT_SECRET='<32-byte random>' \
-e SUPER_ADMIN_PASSWORD='<owner initial password>' \
-e SEED_DEMO=false \
-v petshop-data:/app/data \
petshop:1.2.0
C. Marketplace one-click deploy
Choose this template in the deploy form and keep the port at 8080. The platform starts the container from
intematrix.deploy.json and injects PORT / BIND_HOST. Open the assigned domain; /api/health returning
status: ok means it is healthy.
Do not run multiple replicas: SQLite is a single file. Horizontal scaling requires moving the business tables to MySQL/PostgreSQL first (no such migrations ship with the package; see §7).
2. What runs in the container
| Path | Content |
|---|---|
/app/server/index.js |
Backend bundle (Elysia + business API + SPA static hosting) |
/app/public |
Front-end artifacts (index.html, assets/*, config.js, .build-meta.json) |
/app/drizzle |
Migrations (sqlite/ only in this package, applied on start) |
/app/data |
Persistent volume: sqlite.db, backups/ |
One process serves / (SPA), /api/* (business), /docs (Swagger), /config.js (runtime config) and /api/health.
3. How front end and back end meet (config.js)
The front end does not bake in the API address; it loads /config.js before the bundle:
<!-- apps/web/index.html (dist/index.html after build) -->
<script src="./config.js"></script>
<script type="module" src="./assets/index-xxxx.js"></script>
- In the container:
apps/apiintercepts/config.jsinonRequestand emitswindow.__IMX_CONFIG__ = { apiMode: "http", apiBase: "/api" }withcache-control: no-store.onRequestis used becausedist/also contains a staticconfig.jsand the static plugin would win. - Marketplace preview: the preview service injects
apiMode: "mock", so the same artifact runs on the in-browser demo engine (no backend required). PUBLIC_API_MODE=mock: forces demo mode in self-hosting (diagnostics only; do not use in production).
The front end trusts only this runtime value and never probes /api/health. To check the current mode in a
browser console: document.documentElement.dataset.apiMode (http or mock).
4. Environment variables
| Variable | Default | Required | Notes |
|---|---|---|---|
NODE_ENV |
development |
set production |
Enables static hosting and disables demo seeding (unless SEED_DEMO=true) |
PORT |
3000 (Dockerfile fixes 8080) |
no | Public port; the platform injects it |
BIND_HOST |
0.0.0.0 |
no | Bind address; do not use HOST (that is the public domain) |
PUBLIC_DIR |
./public (/app/public in container) |
no | Front-end artifact directory |
PUBLIC_API_MODE |
http |
no | Value emitted by /config.js; mock for demo diagnostics only |
PUBLIC_API_BASE |
/api |
no | Front-end API prefix (unchanged for same-domain reverse proxy) |
DB_DRIVER |
sqlite |
no | sqlite only (the only migration set shipped) |
DATABASE_URL |
/app/data/sqlite.db |
no | SQLite file path |
MIGRATIONS_DIR |
./drizzle (/app/drizzle) |
no | Migration directory |
JWT_SECRET |
dev-secret-change-me |
yes | Token signing key; must be random in production |
SUPER_ADMIN_EMAIL |
admin@example.com |
recommended | Owner account |
SUPER_ADMIN_NAME |
店主 |
no | Owner display name |
SUPER_ADMIN_PASSWORD |
Admin@123456 |
yes | Owner initial password (used only when the account is created) |
SEED_DEMO |
true in dev / false in prod |
no | Seed demo staff and demo master data |
CORS_ORIGIN |
* |
no | Tighten to your front-end origin if it is on another domain |
Passwords are stored as Argon2 hashes in
app/data(no plaintext). ChangingSUPER_ADMIN_PASSWORDdoes not overwrite an existing account (seeding is idempotent); use Members → Reset password instead.
5. Local development
bun install
bun run dev # web 5173 + api 3000 in parallel
- Front end:
http://localhost:5173(Vite proxies/apito 3000; override withVITE_API_PROXYorAPI_PORT). - Back end:
http://127.0.0.1:3000, Swagger at/docs. - Database:
apps/api/data/sqlite.db(relative to the start directory); first start migrates and seeds. - Request mode:
.env.development= mock (front end alone),.env.production= http,bun run dev:httpforces http. - Demo only:
bun run dev:web, then openhttp://localhost:5173/?mode=preview#/console.
Dev ports 3000/5173 are not deployment ports. Deployment only knows 8080; there is no "3000 locally, 8080 on the platform" dual convention in the compose file or docs.
6. Data and backup
- SQLite single file:
/app/data/sqlite.db(must be a volume, otherwise a rebuilt container loses everything). - Every business write appends to
audit_log(operator, action, before/after, reason, IP); append-only. - Manual backup: Settings → Backup & export → Back up now (
POST /api/petshop/backup); files land in/app/data/backups/. There is no download endpoint; take files from the volume/host. - Cold backup (recommended): stop the container → copy
sqlite.dbandbackups/→ start again. - Restore: stop → overwrite
sqlite.dbfrom a backup (delete-wal/-shmif present) → start. - Suggested schedule:
cp sqlite.db backup/sqlite-$(date +%F).db, or the online-safesqlite3 db ".backup out.db".
7. Switching database (SQLite is the only shipped dialect)
Only SQLite ships as a business dialect: apps/api/src/petshop/db/schema.sqlite.ts +
apps/api/drizzle/sqlite/ (one initial migration). The base layer (accounts / roles / permissions) also has
apps/api/src/db/schema/mysql.ts and postgres.ts as reference source, but there are no business migration
directories for them; starting with DB_DRIVER=mysql will fail when creating business tables.
If you really need another database, fill the gap yourself (this is customisation):
- Add
schema.mysql.ts/schema.postgres.tsunderapps/api/src/petshop/db/with the same columns as the SQLite schema; - Generate the migration folders under
apps/api/drizzle/(drizzle-kit generate, seeapps/api/drizzle.config.ts); - All
petshop/db/helpers.tsSQL is parameterised templates — run every statement against the target database; - Regress completely: settlement, card deduction, card refund, stocktake, boarding settlement, reports (money and stock are the riskiest);
- Only then switch production.
You do not need another database to scale reads: SQLite allows many readers and one writer, and a single container handles a normal shop (tens of orders a day) comfortably.
8. Reverse proxy and HTTPS
Same-domain reverse proxy (recommended): forward everything to container port 8080. The front end uses relative
/api, so CORS_ORIGIN can stay untouched.
server {
listen 443 ssl http2;
server_name shop.example.com;
ssl_certificate /etc/letsencrypt/live/shop.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/shop.example.com/privkey.pem;
client_max_body_size 20m;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
}
}
/and/config.jsareno-store: after a redeploy the browser will not hold an old HTML that references a deleted hash chunk.assets/*are content-hashed and can be cached long.- Front end and back end on different domains: point
PUBLIC_API_BASEat the API and tightenCORS_ORIGIN.
9. Upgrade and rollback
# 1) back up (see §6)
# 2) rebuild the image
docker compose up -d --build
# 3) health check
curl -s http://localhost:8080/api/health | head
- Migrations run at start and are idempotent; SQLite column additions are backwards compatible.
- Restart the container after a rebuild before verifying: Elysia's static plugin warms its file table at start,
so a rebuilt
distwithout a restart serves missing hash JS (blank page, no console error). - Rollback: switch back to the previous image tag and restore
sqlite.db. Back up first — a newer migration may have added columns.
10. Troubleshooting
| Symptom | Check first | Action |
|---|---|---|
| 502 / cannot connect | docker compose ps healthy? curl localhost:8080/api/health |
Confirm all five port layers are 8080; container must bind 0.0.0.0 (BIND_HOST) |
| Blank page, no console error | Did you restart after rebuilding? | Restart the container (static table is warmed at start) |
| Old page / deleted JS referenced | cache-control headers |
/ and /config.js must be no-store; do not cache HTML in the proxy |
| Demo data after login, resets on refresh | document.documentElement.dataset.apiMode; curl /config.js |
Should be http; unset PUBLIC_API_MODE=mock |
| One endpoint 404s, others work | curl /api/health → features |
Missing petshop.* means an older image; redeploy |
| Login 401 | Account exists/active? password reset? | Reset the password as owner under Members |
| Login 429 | Five failures within 15 min lock for 5 min | Wait, or restart the process (in-memory counter) |
| A button returns 403 | 缺少权限:xxx / 该操作仅店主可执行 |
Change the account's role per Roles & Permissions; owner-only actions need the owner |
| Bounced to change-password on login | mustChangePassword=true |
Expected for handed-out passwords; changing it clears the flag |
| Receipt does not print | Browser print dialog, 58/80 mm paper | Edit the template under Receipt template; printing uses the browser |
| Data gone after container restart | Is /app/data mounted? |
Add -v petshop-data:/app/data; docker compose down -v deletes the volume |
SQLite database is locked |
Multiple replicas/processes on one file? | Single replica only; or migrate per §7 (add the dialect yourself) |
| Marketplace rejects the upload | Output of bun run verify:upload |
Fix item by item: .build-meta.json must be http, dist/config.js present, docs/rag complete |
11. Packaging and upload (customisers)
bun install
bun run pack:upload
# = check → check:i18n → test → build → check:dist → pack → verify:upload
- Only a production build is accepted:
apps/web/dist/.build-meta.jsonmust sayapiMode: http. - Must contain:
apps/web/dist/index.html+assets/*+config.js,apps/api/out/index.js,apps/api/drizzle/**. - Packaging uses
scripts/zip-pack.py(Python zipfile; non-ASCII names get the UTF-8 flag 0x800). Do not use Windowstar.exe -a -c, or document titles will be mojibake in the marketplace. bun run verify:uploadmust be fully green (this template is single-container, so the three multi-container checks are not applicable).- The package must not contain
node_modules,data/,*.log,sqlite.db, real.envfiles or keys.
12. Rebuilding after customisation
- Change code: rules in
packages/shared/src/business.ts, API inapps/api/src/petshop/**, pages inapps/web/src/petshop/**. bun run check+bun test(291 cases) +bun run check:i18n.bun run build→bun run check:dist(must printhttp).docker compose up -d --build(the image copiesapps/web/distandapps/api/out, so build before building the image).- If tables changed:
bun run --filter api db:generate, then restart the container.
13. Domains and platform conventions
- The platform assigns domains as
{container}.{deploymentId}.{baseDomain}. Do not hardcode domains or callbacks. - Bind with
BIND_HOST(default0.0.0.0);HOSTis the container's public domain, not a bind address. - Inter-container traffic (not used here) uses container-name DNS or the platform-injected
<NAME>_HOST/_PORT/_IP. - Do not put
network.subnetor a fixed containeripin the deploy manifest: the platform allocates the subnet and fixed values fail preflight.
14. Health self-check
curl -s http://localhost:8080/api/health
Expected:
{
"status": "ok",
"service": "api",
"version": "1.2.0",
"features": ["app.identity", "petshop.auth", "petshop.staff", "petshop.members",
"petshop.pets", "petshop.appointments", "petshop.workorders", "petshop.boarding",
"petshop.cashier", "petshop.cards", "petshop.inventory", "petshop.reports",
"petshop.settings"],
"startedAt": "…",
"timestamp": "…"
}
Troubleshooting order: features → /config.js apiMode → browser console.
A missing capability name means an older image, not broken code; a present name with a 404 is a code issue.
Frequently asked questions
- What do I get after purchase?
- The full source code (web frontend + API backend), deployment documentation and an online preview. After purchase you can download it from "My Projects" and use it for your own product.
- Can it be deployed to my own server?
- The Web + API edition supports one-click private deployment, so data stays on your own infrastructure. Mini-program and App add-on packages are not one-click deployable.
- Can I get a refund?
- Orders whose code package has not been downloaded can request a refund through a support ticket. Once the code package has been downloaded, refunds are not supported.
- How do I reach support?
- Open "My Projects" and click "Support" to submit a ticket. Staff reply inside the ticket, and status changes are pushed as WeChat notifications.
