Running an instance #
This runs the published image lgtmsupplyco/commerce as your own storefront instance.
The reference implementation is Postgres-canonical; you supply a Postgres, a master key,
and per-store config. Start in fake-payments mode (browsable, no external accounts),
then cut over to real payments.
Prerequisites #
- A Postgres 16 database.
- A base64-encoded 32-byte
LGTM_MASTER_KEY. Generate one:openssl rand -base64 32 - A base64
LGTM_SESSION_SECRET:openssl rand -base64 32.
Architecture: the image is currently
linux/amd64only (no arm64 manifest). Cloud hosts (Railway, Fly, etc.) run amd64, so this is a non-issue there. On Apple Silicon / Colima, force the platform:export DOCKER_DEFAULT_PLATFORM=linux/amd64(or pass--platform linux/amd64) — it runs fine under emulation.
Boot behavior #
The image entrypoint is server --role all: it runs migrations (advisory-locked) then
serves the HTTP API + admin UI and the apalis worker in one process. It listens on
$PORT (default 8080).
Environment #
See the table in the README. Minimum for a fake-payments instance:
LGTM_TENANCY=single
LGTM_DATABASE_URL=postgres://USER:PASS@HOST:5432/lgtm
LGTM_MASTER_KEY=<base64 32 bytes>
LGTM_SESSION_SECRET=<base64 32 bytes>
LGTM_PUBLIC_URL=https://your-instance.example
LGTM_STORE_DID=did:web:your-instance.example
LGTM_ATPROTO_OAUTH_CLIENT_ID=https://your-instance.example/client-metadata.json
LGTM_FAKE_PAYMENTS=1
# fake mode ignores the values but they must be non-empty:
LGTM_STRIPE_SECRET_KEY=x
LGTM_STRIPE_WEBHOOK_SECRET=x
LGTM_PRINTFUL_API_KEY=x
LGTM_PRINTFUL_WEBHOOK_SECRET=x
Seed the store (one-off) #
--role seed runs a one-shot: migrate, create a tenant + an ES256 store signing key
(sealed with LGTM_MASTER_KEY — it MUST match the app's) + a storefront record + a demo
product, then exit. Run it once against the same database and env:
docker run --rm --env-file .env lgtmsupplyco/commerce:v0.2.1 --role seed
(v0.2.1+: seeding is a role of the main binary — no entrypoint override. On older images
use --entrypoint /usr/local/bin/seed-demo.)
Importing the Printful catalog #
With LGTM_PRINTFUL_API_KEY set, pull your Printful store's sync products into
the local catalog (one-shot, safe to re-run — refreshes titles/prices/SKUs,
never deletes, never overwrites local availability):
docker run --rm --env-file .env lgtmsupplyco/commerce:v0.2.3 --role import
(v0.2.3+: --role import is supported. On older images the flag is ignored and
the server boots normally — pin the tag to avoid this.)
The import also sets each Printful sync variant's external_id to the local
variant id. This is required for fulfillment: order submission references
variants by that id. Run the import at least once before going live, and re-run
it after adding or repricing products in Printful. Skipped or failed variants
are listed as warnings in the summary but the command still exits 0 — review
the summary (especially any "FULFILLMENT AT RISK" warnings) before going live.
Railway quickstart #
- New Project → Deploy from Docker image →
lgtmsupplyco/commerce:v0.2.1. - Add a Postgres plugin. In the service variables, set
LGTM_DATABASE_URL = ${{Postgres.DATABASE_URL}}(Railway exposesDATABASE_URL; the app reads theLGTM_-prefixed name). - Set the rest of the env from the block above. Leave
PORTunset — Railway injects it and the app binds it automatically. - Seed: run the one-off with the same env — override the service's start command to
--role seedfor one run (orrailway run … lgtmsupplyco/commerce:v0.2.1 --role seed). No restart needed afterwards — the worker polls for the signing key and self-starts (v0.2.0+). - Open the Railway-provided URL; the storefront is browsable.
- Attach your custom domain (
lgtm.shop) in Railway settings; TLS is automatic.
Verify the instance #
GET /healthzreturns 200 with JSON{"status":"ok","version":"<VERSION>","commit":"<git-sha>"}— use it to confirm which image is deployed.GET /readyzreturns 200 when DB + integrations are healthy.- Storefront is browsable at the public URL.
- Full fake-payment loop: create a checkout → open the returned
/dev/pay?order_id=…URL → the worker fulfills → a signed ES256 receipt is written → the order reachesFulfilled.
Store identity — connecting your DID #
Receipts are signed with the store's ES256 key; a verifier trusts a receipt by resolving
your store DID → that key (SPEC §9). So the key must be published under your DID. The
backend holds the key and exposes its public half; how you publish it depends on your DID
method (LGTM_STORE_DID can be any DID — it's opaque to the backend):
GET /api/signing-key(any DID method) returns the key as a ready-to-register verification method:{ "did": "<LGTM_STORE_DID>", "verificationMethod": { id, type: "Multikey", controller, publicKeyMultibase } }. 404 until the store is seeded.did:web:<host>store → also served as a full DID document atGET /.well-known/did.json; front it at the host root (e.g. an SSR frontend proxieshttps://<host>/.well-known/did.jsonto the backend). Nothing else to do.did:plc:…store (the atproto default) →/.well-known/did.jsondoes not apply (adid:plcresolves via the PLC directory). Take theverificationMethodfrom/api/signing-keyand add it to your DID document via a PLC operation (signed with your account's rotation key — you control the DID, the backend can't). Once atproto repo writes land (deferred in P1), the idiomatic alternative is publishing it as ashop.lgtm.commerce.attestationKeyrecord in your repo, which works for any DID method.
(This only gates external receipt verification — the store operates and stores signed receipts regardless, so it's not required for the demo.)
Admin #
- Admin UI (
/admin/*) is not operable yet. It gates on atproto OAuth, which is stubbed in this reference implementation (the callback is a501; no client-metadata document or token exchange). Real atproto OAuth (PAR + DPoP + authorization-server discovery) is a planned follow-up. Until then, provision the store with--role seedand manage catalog via the DB / API; the customer-facing storefront needs no admin login.
Go-live cutover (real money) #
When you're ready to take real orders:
- Set
LGTM_FAKE_PAYMENTS=0. - Set the real keys in the env — these are read directly (single-tenant):
LGTM_STRIPE_SECRET_KEY,LGTM_STRIPE_WEBHOOK_SECRET,LGTM_PRINTFUL_API_KEY,LGTM_PRINTFUL_WEBHOOK_SECRET. - Stripe webhook: in the Stripe Dashboard add an endpoint at
https://<public-url>/webhooks/stripefor eventscheckout.session.completed+charge.refunded; copy its signing secret (whsec_…) intoLGTM_STRIPE_WEBHOOK_SECRET. - Printful webhook: Printful does not sign webhooks, so the backend authenticates via a
secret token in the URL. Set
LGTM_PRINTFUL_WEBHOOK_SECRETto a URL-safe random token (e.g.openssl rand -hex 16), then in the Printful Dashboard register the webhook URL ashttps://<public-url>/webhooks/printful?token=<that token>. Keep the token URL-safe — it is compared verbatim, not URL-decoded. The backend handles thepackage_shippedevent (marks the order's fulfillmentshippedand stores the carrier tracking). The core payment→fulfillment path (checkout → Stripe → worker submits the Printful order via API) works without it; the webhook only syncs shipment status back. - Confirm
LGTM_PUBLIC_URL,LGTM_STORE_DID, and your custom domain are the real ones. - Redeploy and run a real low-value test order end-to-end before announcing.
Trusted channels (optional) #
If your deployment fronts the write plane with a transport that cryptographically verifies
buyer DIDs (e.g. an SSH storefront gateway), enable channel assertions so a claimed
buyerDid must be proven:
LGTM_CHANNEL_ASSERTION_SECRET— shared HS256 secret; give the same value to the transport (e.g. a Railway shared variable). Setting it turns the feature on.LGTM_CHANNEL_ASSERTION_AUDIENCE— expected JWTaud; defaults toLGTM_STORE_DID.LGTM_LINK_URL— base URL for device-link pages shown to buyers ({base}/{code}); defaults to{shop_url}/link.
The transport sends the assertion as an X-Channel-Assertion header on write-plane calls
and on the /api/link/* device-linking endpoints (see REFERENCE §8). Deployments without
a trusted channel leave the secret unset and are unaffected.
Consuming the image from your own repo #
Your instance repo (e.g. lgtm-shop/lgtm.shop) does not need the source. It holds a
compose or Railway config that pins the image tag plus your secrets. See
docker-compose.prod.yml for the shape — copy it, add a
.env, and bump the pinned tag to upgrade.