Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

2.6 KB
Raw Blame
# Internal Spree development overlay — mounts a local checkout of the
# spree/spree monorepo at the same path inside the container so the
# Gemfile's path-based gem block (`path "#{ENV['SPREE_PATH']}/spree"`)
# resolves identically on the host and in the container.
#
# Activate by chaining this file after the dev compose:
#
#   SPREE_PATH=/absolute/host/path/to/spree-monorepo \
#     docker compose -f docker-compose.dev.yml -f docker-compose.edge.yml \
#     up -d --force-recreate web
#
# Without -f docker-compose.edge.yml, regular dev usage is unaffected:
# no extra mounts, no SPREE_PATH dependency, runs identically on
# Docker Desktop, OrbStack, and stock Docker Engine on Linux.
#
# Gotcha: enabling edge rewrites Gemfile.lock with a PATH block pointing
# at the host monorepo. Run `git checkout Gemfile.lock` before committing
# unrelated changes.

services:
  web:
    # Override SPREE_PATH inside the container to match the absolute host
    # path we mirror-mount. The starter's .env may carry a different
    # SPREE_PATH (e.g. `..` for the native bin/dev flow); the overlay-set
    # value here wins because `environment:` beats `env_file:` in Compose.
    #
    # The React dashboard and seller panel are NOT served through Rails in
    # this flow — the spree_dashboard gem's dist hosting is a production
    # (single-node) topology, and a static build goes stale on every git
    # pull. Run them as their own dev servers instead: `pnpm dashboard:dev`
    # and `pnpm seller:dev` (both proxy /api to localhost:3000 by default).
    # To test the hosted path deliberately, build a dist (`pnpm
    # server:dashboard` / `pnpm server:seller`) and set
    # SPREE_DASHBOARD_DIST_PATH / SPREE_SELLER_PANEL_DIST_PATH here yourself.
    environment:
      SPREE_PATH: ${SPREE_PATH}
    volumes:
      - ${SPREE_PATH}:${SPREE_PATH}
    # Hard-bypass the starter's bin/docker-entrypoint, which auto-runs
    # `db:prepare` when the command is `bin/rails server`. The dev compose
    # claims to bypass it but doesn't actually set entrypoint: [], so we
    # do it here.
    entrypoint: []
    # Self-healing boot. Monorepo pulls and starter updates routinely drift
    # Gemfile.lock ahead of the bundle_cache volume and add new engine
    # migrations — without this, web crash-loops on Bundler::GemNotFound
    # or 500 on ActiveRecord::PendingMigrationError after every such pull.
    # `bundle check` is sub-second when clean; the rails invocation is one
    # boot (~5s) that no-ops when nothing changed.
    command:
      [
        "sh", "-c",
        "(bundle check || bundle install) && bin/rails spree:install:migrations db:prepare && exec bin/rails server -b 0.0.0.0 -p 3000"
      ]