@spree/docs 0.1.129 → 0.1.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/developer/contributing/developing-spree.md +2 -2
- package/dist/developer/core-concepts/reports.md +1 -1
- package/dist/developer/create-spree-app/quickstart.md +34 -14
- package/dist/developer/dashboard/deployment.md +8 -12
- package/dist/developer/deployment/aws.md +77 -434
- package/dist/developer/deployment/aws_ecs.md +460 -0
- package/dist/developer/deployment/background_jobs.md +106 -0
- package/dist/developer/deployment/caching.md +15 -7
- package/dist/developer/deployment/database.md +4 -4
- package/dist/developer/deployment/docker.md +50 -58
- package/dist/developer/deployment/emails.md +27 -19
- package/dist/developer/deployment/environment_variables.md +33 -21
- package/dist/developer/deployment/quickstart.md +79 -0
- package/dist/developer/deployment/render.md +28 -42
- package/package.json +1 -1
- package/dist/developer/deployment/heroku.md +0 -51
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Docker
|
|
3
|
-
description:
|
|
3
|
+
description: Build a production Docker image of your Spree project, or run the official prebuilt image.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
##
|
|
6
|
+
## Building Your Project's Image
|
|
7
|
+
|
|
8
|
+
Every [create-spree-app](../create-spree-app/quickstart.md) project builds into a single production image: the web server and background jobs run in one container, and the only dependency is a PostgreSQL database (the [single-node topology](quickstart.md#single-node-vs-distributed)).
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
If you haven't ejected yet, do that first:
|
|
9
11
|
|
|
10
12
|
```bash
|
|
11
|
-
|
|
13
|
+
spree eject
|
|
12
14
|
```
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
This generates the app source — including its production `Dockerfile` — in `backend/`. Make your customizations, then build:
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
| `5.4` | Latest patch for a minor version |
|
|
18
|
+
```bash
|
|
19
|
+
spree build --production # → <project>-spree:latest
|
|
20
|
+
spree build --production --tag registry.example.com/my-store:v42
|
|
21
|
+
```
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
Or with plain Docker, from the project root:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
docker build . -f backend/Dockerfile -t my-store
|
|
27
|
+
```
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
Both produce the same image — and it's exactly what Render and Railway build from your repository. Migrations run automatically on boot.
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
## Running the Image
|
|
32
|
+
|
|
33
|
+
One app container plus Postgres is a complete deployment:
|
|
27
34
|
|
|
28
35
|
```yaml docker-compose.yml
|
|
29
36
|
services:
|
|
30
37
|
postgres:
|
|
31
|
-
image: postgres:
|
|
38
|
+
image: postgres:18-alpine
|
|
32
39
|
environment:
|
|
33
40
|
POSTGRES_HOST_AUTH_METHOD: trust
|
|
34
41
|
volumes:
|
|
@@ -39,26 +46,13 @@ services:
|
|
|
39
46
|
timeout: 5s
|
|
40
47
|
retries: 5
|
|
41
48
|
|
|
42
|
-
redis:
|
|
43
|
-
image: redis:7-alpine
|
|
44
|
-
volumes:
|
|
45
|
-
- redis_data:/data
|
|
46
|
-
healthcheck:
|
|
47
|
-
test: redis-cli ping
|
|
48
|
-
interval: 5s
|
|
49
|
-
timeout: 5s
|
|
50
|
-
retries: 5
|
|
51
|
-
|
|
52
49
|
web:
|
|
53
|
-
image: ghcr.io/spree/spree:latest
|
|
50
|
+
image: my-store # or ghcr.io/spree/spree:latest for the stock image
|
|
54
51
|
depends_on:
|
|
55
52
|
postgres:
|
|
56
53
|
condition: service_healthy
|
|
57
|
-
redis:
|
|
58
|
-
condition: service_healthy
|
|
59
54
|
environment:
|
|
60
55
|
DATABASE_URL: postgres://postgres@postgres:5432/spree_production
|
|
61
|
-
REDIS_URL: redis://redis:6379/0
|
|
62
56
|
SECRET_KEY_BASE: change-me-to-a-real-secret
|
|
63
57
|
RAILS_FORCE_SSL: "false"
|
|
64
58
|
RAILS_ASSUME_SSL: "false"
|
|
@@ -74,21 +68,8 @@ services:
|
|
|
74
68
|
retries: 10
|
|
75
69
|
start_period: 30s
|
|
76
70
|
|
|
77
|
-
worker:
|
|
78
|
-
image: ghcr.io/spree/spree:latest
|
|
79
|
-
depends_on:
|
|
80
|
-
web:
|
|
81
|
-
condition: service_healthy
|
|
82
|
-
environment:
|
|
83
|
-
DATABASE_URL: postgres://postgres@postgres:5432/spree_production
|
|
84
|
-
REDIS_URL: redis://redis:6379/0
|
|
85
|
-
SECRET_KEY_BASE: change-me-to-a-real-secret
|
|
86
|
-
RAILS_HOST: localhost:3000
|
|
87
|
-
command: bundle exec sidekiq
|
|
88
|
-
|
|
89
71
|
volumes:
|
|
90
72
|
postgres_data:
|
|
91
|
-
redis_data:
|
|
92
73
|
```
|
|
93
74
|
|
|
94
75
|
Start everything:
|
|
@@ -97,37 +78,48 @@ Start everything:
|
|
|
97
78
|
docker compose up -d
|
|
98
79
|
```
|
|
99
80
|
|
|
100
|
-
The database is
|
|
81
|
+
The database is created and migrated on first boot. The app is available at [http://localhost:3000](http://localhost:3000).
|
|
101
82
|
|
|
102
|
-
|
|
83
|
+
### Scaling out the worker
|
|
84
|
+
|
|
85
|
+
Background jobs run inside the web container by default. When job load deserves its own process, split it out — same image, no rebuild: set `SOLID_QUEUE_IN_PUMA: "false"` on `web` and add a worker service:
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
worker:
|
|
89
|
+
image: my-store
|
|
90
|
+
depends_on:
|
|
91
|
+
postgres:
|
|
92
|
+
condition: service_healthy
|
|
93
|
+
environment:
|
|
94
|
+
DATABASE_URL: postgres://postgres@postgres:5432/spree_production
|
|
95
|
+
SECRET_KEY_BASE: change-me-to-a-real-secret
|
|
96
|
+
RAILS_HOST: localhost:3000
|
|
97
|
+
command: bin/jobs
|
|
98
|
+
```
|
|
103
99
|
|
|
104
100
|
### Required Environment Variables
|
|
105
101
|
|
|
106
102
|
| Variable | Description | Example |
|
|
107
103
|
| --- | --- | --- |
|
|
108
104
|
| `DATABASE_URL` | PostgreSQL connection URL | `postgres://user:pass@host:5432/spree` |
|
|
109
|
-
| `REDIS_URL` | Redis URL for jobs, caching, and Action Cable | `redis://redis:6379/0` |
|
|
110
105
|
| `SECRET_KEY_BASE` | Secret key for session encryption | Generate with `bin/rails secret` |
|
|
111
|
-
| `RAILS_HOST` | Public host used in generated URLs — image/attachment URLs in API responses, email links
|
|
106
|
+
| `RAILS_HOST` | Public host used in generated URLs — image/attachment URLs in API responses, email links | `store.example.com` |
|
|
107
|
+
| `SOLID_QUEUE_IN_PUMA` | Run background jobs inside the web container (default `true`); set `false` when running a dedicated worker | `true` |
|
|
112
108
|
|
|
113
109
|
See [Environment Variables](environment_variables.md) for the full list.
|
|
114
110
|
|
|
115
|
-
##
|
|
111
|
+
## Official Docker Image
|
|
116
112
|
|
|
117
|
-
|
|
113
|
+
To run Spree without any customizations, pull the prebuilt multi-arch image (`linux/amd64` and `linux/arm64`) published to the GitHub Container Registry on every release:
|
|
118
114
|
|
|
119
115
|
```bash
|
|
120
|
-
docker
|
|
116
|
+
docker pull ghcr.io/spree/spree:latest
|
|
121
117
|
```
|
|
122
118
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
-e REDIS_URL=redis://localhost:6379/0 \
|
|
129
|
-
-e SECRET_KEY_BASE=your-secret \
|
|
130
|
-
my-spree
|
|
131
|
-
```
|
|
119
|
+
| Tag | Description |
|
|
120
|
+
|-----|-------------|
|
|
121
|
+
| `latest` | Latest stable release |
|
|
122
|
+
| `5.4.0` | Specific version |
|
|
123
|
+
| `5.4` | Latest patch for a minor version |
|
|
132
124
|
|
|
133
|
-
|
|
125
|
+
Browse all tags on the [GitHub Packages page](https://github.com/spree/spree/pkgs/container/spree). The image drops into the compose file above in place of your custom tag.
|
|
@@ -8,19 +8,25 @@ Spree handles two categories of emails:
|
|
|
8
8
|
|
|
9
9
|
| Category | Sent by | Examples |
|
|
10
10
|
|----------|---------|----------|
|
|
11
|
-
| **Customer-facing** |
|
|
12
|
-
| **System/admin** | Spree
|
|
11
|
+
| **Customer-facing** | Spree by default; optionally your storefront (via webhooks) | Order confirmation, shipping notification, password reset |
|
|
12
|
+
| **System/admin** | Spree | Staff invitation, report ready, export complete |
|
|
13
13
|
|
|
14
|
-
## Customer-Facing Emails
|
|
14
|
+
## Customer-Facing Emails
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
By default, **Spree sends all customer transactional emails itself** — the `spree_emails` gem ships installed in every deployment. This works for every client of the API: mobile apps, custom frontends, POS integrations — no storefront required. Delivery uses the same [SMTP configuration](#configuration) as system emails.
|
|
17
|
+
|
|
18
|
+
Customer emails can be turned off in the admin under **Settings → Emails** — do this when your storefront takes over sending them (below), otherwise customers receive both.
|
|
19
|
+
|
|
20
|
+
### Sending from the Storefront Instead
|
|
21
|
+
|
|
22
|
+
With the Next.js storefront, you can let the storefront own the customer email experience: the Spree backend publishes webhook events, and the storefront receives them, renders React email templates, and sends via [Resend](https://resend.com) (or any provider).
|
|
17
23
|
|
|
18
24
|
```
|
|
19
25
|
Spree Backend → Webhook POST → Storefront → render email → send via Resend
|
|
20
26
|
(HMAC signed) (verified) (react-email)
|
|
21
27
|
```
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
#### Setup
|
|
24
30
|
|
|
25
31
|
1. **Create a webhook endpoint** in Spree Admin → Settings → Developers → Webhooks:
|
|
26
32
|
- **URL:** `https://your-storefront.com/api/webhooks/spree`
|
|
@@ -28,16 +34,18 @@ Spree Backend → Webhook POST → Storefront → render email → send via Rese
|
|
|
28
34
|
|
|
29
35
|
2. **Configure the storefront** with the webhook secret and email provider:
|
|
30
36
|
|
|
31
|
-
```env
|
|
32
|
-
# .env.local (storefront)
|
|
33
|
-
SPREE_WEBHOOK_SECRET=your_webhook_endpoint_secret_key
|
|
34
|
-
RESEND_API_KEY=re_your_resend_api_key
|
|
35
|
-
EMAIL_FROM=Your Store <orders@your-domain.com>
|
|
36
|
-
```
|
|
37
|
+
```env
|
|
38
|
+
# .env.local (storefront)
|
|
39
|
+
SPREE_WEBHOOK_SECRET=your_webhook_endpoint_secret_key
|
|
40
|
+
RESEND_API_KEY=re_your_resend_api_key
|
|
41
|
+
EMAIL_FROM=Your Store <orders@your-domain.com>
|
|
42
|
+
```
|
|
37
43
|
|
|
38
44
|
3. **The storefront handles everything else** — signature verification, event routing, email rendering, and delivery are built in. See the [Next.js storefront email docs](../storefront/nextjs/customization.md#transactional-emails) for template customization.
|
|
39
45
|
|
|
40
|
-
|
|
46
|
+
4. **Turn off Spree's own customer emails** under **Settings → Emails** in the admin, so customers don't receive duplicates.
|
|
47
|
+
|
|
48
|
+
#### Supported Events
|
|
41
49
|
|
|
42
50
|
| Event | Email |
|
|
43
51
|
|-------|-------|
|
|
@@ -47,7 +55,7 @@ EMAIL_FROM=Your Store <orders@your-domain.com>
|
|
|
47
55
|
| `customer.password_reset_requested` | Password reset link |
|
|
48
56
|
| `newsletter_subscriber.subscription_requested` | Newsletter double opt-in confirmation link |
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
#### Custom Frameworks
|
|
51
59
|
|
|
52
60
|
If you're not using the Next.js storefront, you can build your own webhook handler with any framework. Use `@spree/sdk/webhooks` for signature verification:
|
|
53
61
|
|
|
@@ -57,9 +65,9 @@ import { verifyWebhookSignature } from '@spree/sdk/webhooks'
|
|
|
57
65
|
|
|
58
66
|
See [Webhooks documentation](../core-concepts/webhooks.md) for the full payload format and verification details.
|
|
59
67
|
|
|
60
|
-
## System Emails
|
|
68
|
+
## System Emails
|
|
61
69
|
|
|
62
|
-
System emails are internal notifications sent to **store staff**, not customers. They are sent by
|
|
70
|
+
System emails are internal notifications sent to **store staff**, not customers. They are always sent by Spree itself and can't be taken over by a storefront.
|
|
63
71
|
|
|
64
72
|
| Email | When |
|
|
65
73
|
|-------|------|
|
|
@@ -71,7 +79,7 @@ System emails are internal notifications sent to **store staff**, not customers.
|
|
|
71
79
|
|
|
72
80
|
### Configuration
|
|
73
81
|
|
|
74
|
-
Set the following environment variables on the **Spree backend** to enable
|
|
82
|
+
Set the following environment variables on the **Spree backend** to enable email delivery — this configuration powers both customer transactional emails and system emails:
|
|
75
83
|
|
|
76
84
|
| Variable | Default | Description |
|
|
77
85
|
| --- | --- | --- |
|
|
@@ -128,7 +136,7 @@ When `SMTP_HOST` is not set, emails are printed to the Rails log instead of bein
|
|
|
128
136
|
|
|
129
137
|
## Local Development
|
|
130
138
|
|
|
131
|
-
###
|
|
139
|
+
### Storefront-sent emails
|
|
132
140
|
|
|
133
141
|
In development, no email provider is needed. Emails are rendered to HTML files in `.next/emails/` with a clickable `file://` link in the console. To preview and design templates:
|
|
134
142
|
|
|
@@ -145,6 +153,6 @@ cloudflared tunnel --url http://localhost:3001
|
|
|
145
153
|
|
|
146
154
|
Use the tunnel URL as the webhook endpoint URL in Spree Admin.
|
|
147
155
|
|
|
148
|
-
###
|
|
156
|
+
### Spree-sent emails
|
|
149
157
|
|
|
150
|
-
|
|
158
|
+
In development, all emails Spree sends (customer and system alike) are captured by [Mailpit](https://mailpit.axllent.org/) — nothing is delivered externally. Open **http://localhost:8025** to read them. To deliver through a real provider instead, set `SMTP_HOST` (and friends) in `.env`.
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Environment Variables
|
|
3
|
-
description: Reference for Spree deployment environment variables — database,
|
|
3
|
+
description: Reference for Spree deployment environment variables — database, web server, background jobs, SMTP, file storage, and application settings.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
Spree uses environment variables for all deployment configuration. No secrets or credentials are stored in the codebase.
|
|
7
7
|
|
|
8
8
|
## Required
|
|
9
9
|
|
|
10
|
-
These variables are
|
|
10
|
+
These two variables are all a production deployment strictly needs:
|
|
11
11
|
|
|
12
12
|
| Variable | Description | Example |
|
|
13
13
|
| --- | --- | --- |
|
|
14
|
-
| `DATABASE_URL` |
|
|
15
|
-
| `
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
| `DATABASE_URL` | Database connection URL — see [Database Configuration](database.md) | `postgres://user:pass@localhost:5432/spree` |
|
|
15
|
+
| `SECRET_KEY_BASE` | Secret used to encrypt sessions and cookies. Generate with `openssl rand -hex 64` | `2fad5c0b79d25e4765d3018d8c740f8c3a665f0e5c...` |
|
|
16
|
+
|
|
17
|
+
You'll almost always want to set [`RAILS_HOST`](#urls-and-hosts) too — without it, generated URLs point at `localhost`.
|
|
18
18
|
|
|
19
19
|
## URLs and Hosts
|
|
20
20
|
|
|
@@ -25,15 +25,35 @@ These variables are required to run Spree in production.
|
|
|
25
25
|
| Variable | Default | Description |
|
|
26
26
|
| --- | --- | --- |
|
|
27
27
|
| `RAILS_HOST` | — | Public host, optionally with a port — e.g. `store.example.com` or `203.0.113.7:8080`. Host only, no protocol. On [Render](render.md), falls back to the platform-provided `RENDER_EXTERNAL_HOSTNAME`. |
|
|
28
|
-
| `CDN_HOST` | — | Optional host for serving static assets and images, e.g. a CDN distribution in front of your app. Host only, no protocol. Falls back to `RAILS_HOST`. |
|
|
28
|
+
| `CDN_HOST` | — | Optional host for serving static assets and images, e.g. a CDN distribution in front of your app — see [CDN](cdn.md). Host only, no protocol. Falls back to `RAILS_HOST`. |
|
|
29
29
|
|
|
30
30
|
Generated URLs use `https` unless both `RAILS_FORCE_SSL` and `RAILS_ASSUME_SSL` are set to `false` (see [SSL](#ssl)).
|
|
31
31
|
|
|
32
|
+
## Web Server
|
|
33
|
+
|
|
34
|
+
| Variable | Default | Description |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| `PORT` | `3000` | Port the web server listens on |
|
|
37
|
+
| `RAILS_MAX_THREADS` | `3` | Concurrent requests each web server process handles |
|
|
38
|
+
| `WEB_CONCURRENCY` | `1` | Number of web server processes per container. Set to `auto` for one per CPU core — each process needs roughly 1 GB of RAM |
|
|
39
|
+
|
|
40
|
+
## Background Jobs
|
|
41
|
+
|
|
42
|
+
Background jobs (emails, image processing, webhooks, imports) run inside the web container by default — no extra service needed. See [Background Jobs](background_jobs.md) for how this works and when to split out a dedicated worker.
|
|
43
|
+
|
|
44
|
+
| Variable | Default | Description |
|
|
45
|
+
| --- | --- | --- |
|
|
46
|
+
| `SOLID_QUEUE_IN_PUMA` | `true` | Run background jobs inside the web container. Set to `false` when you run a dedicated worker service (`bin/jobs`) |
|
|
47
|
+
| `JOB_THREADS` | `3` | How many background jobs run concurrently. Raise it on a dedicated worker; the database connection pool sizes itself from this |
|
|
48
|
+
| `JOB_CONCURRENCY` | `1` | Number of worker processes — the scaling knob for a dedicated worker |
|
|
49
|
+
| `SPREE_IMPORT_JOB_CONCURRENCY` | 75% of `JOB_THREADS` | How much of the job capacity a single CSV import may occupy, so imports can't starve other work. `0` removes the cap |
|
|
50
|
+
| `MISSION_CONTROL_USER` / `MISSION_CONTROL_PASSWORD` | — | Login for the `/jobs` dashboard (HTTP Basic auth). Required in production — the dashboard stays locked without them |
|
|
51
|
+
|
|
32
52
|
## Email (SMTP)
|
|
33
53
|
|
|
34
|
-
> **TIP:** This configuration
|
|
54
|
+
> **TIP:** This configuration powers all emails Spree sends — customer transactional emails (order confirmation, shipping notification; on by default) and staff notifications. A storefront can optionally take over customer emails via webhooks — see [Emails](emails.md).
|
|
35
55
|
|
|
36
|
-
Spree works with any SMTP provider (Resend, Postmark, Mailgun, SendGrid, Amazon SES, etc.). Set `SMTP_HOST` to enable email delivery — when not set,
|
|
56
|
+
Spree works with any SMTP provider (Resend, Postmark, Mailgun, SendGrid, Amazon SES, etc.). Set `SMTP_HOST` to enable email delivery — when not set, production email delivery is disabled (in development, emails are captured by Mailpit at `http://localhost:8025` instead of being sent). See [Emails](emails.md) for the full guide.
|
|
37
57
|
|
|
38
58
|
| Variable | Default | Description |
|
|
39
59
|
| --- | --- | --- |
|
|
@@ -45,24 +65,16 @@ Spree works with any SMTP provider (Resend, Postmark, Mailgun, SendGrid, Amazon
|
|
|
45
65
|
|
|
46
66
|
Links in emails use the host configured via [`RAILS_HOST`](#urls-and-hosts).
|
|
47
67
|
|
|
48
|
-
## Web Server
|
|
49
|
-
|
|
50
|
-
| Variable | Default | Description |
|
|
51
|
-
| --- | --- | --- |
|
|
52
|
-
| `PORT` | `3000` | Web server port |
|
|
53
|
-
| `RAILS_MAX_THREADS` | `3` | Puma threads per worker |
|
|
54
|
-
| `WEB_CONCURRENCY` | `1` | Number of Puma workers. Set to `auto` for one per CPU core |
|
|
55
|
-
|
|
56
68
|
## Application
|
|
57
69
|
|
|
58
70
|
| Variable | Default | Description |
|
|
59
71
|
| --- | --- | --- |
|
|
60
|
-
| `RAILS_ENV` | `production` |
|
|
72
|
+
| `RAILS_ENV` | `production` | Runtime environment — leave as `production` when deploying |
|
|
61
73
|
| `RAILS_LOG_LEVEL` | `info` | Log level (`debug`, `info`, `warn`, `error`) |
|
|
62
74
|
|
|
63
75
|
## File Storage (S3 / Cloudflare R2)
|
|
64
76
|
|
|
65
|
-
By default, uploaded files (product images, assets) are stored on the local filesystem. Set the appropriate credentials to use cloud storage instead
|
|
77
|
+
By default, uploaded files (product images, assets) are stored on the local filesystem. Set the appropriate credentials to use cloud storage instead — Spree auto-detects the provider based on which credentials are present. See [Asset Storage](assets.md) for the full guide.
|
|
66
78
|
|
|
67
79
|
### Amazon S3
|
|
68
80
|
|
|
@@ -116,11 +128,11 @@ bundle exec rake spree:search:reindex
|
|
|
116
128
|
|
|
117
129
|
## SSL
|
|
118
130
|
|
|
119
|
-
By default, Spree assumes it runs behind an SSL-terminating reverse proxy. Set these to `false` if running without SSL (e.g., local development or behind a proxy that doesn't do SSL termination).
|
|
131
|
+
By default, Spree assumes it runs behind an SSL-terminating reverse proxy or load balancer. Set these to `false` if running without SSL (e.g., local development or behind a proxy that doesn't do SSL termination).
|
|
120
132
|
|
|
121
133
|
| Variable | Default | Description |
|
|
122
134
|
| --- | --- | --- |
|
|
123
|
-
| `RAILS_ASSUME_SSL` | `true` |
|
|
135
|
+
| `RAILS_ASSUME_SSL` | `true` | Treat incoming requests as arriving over HTTPS (trust the proxy's forwarded headers) |
|
|
124
136
|
| `RAILS_FORCE_SSL` | `true` | Redirect HTTP to HTTPS and use secure cookies |
|
|
125
137
|
|
|
126
138
|
## Local Development
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Deployment Overview
|
|
3
|
+
sidebarTitle: Quickstart
|
|
4
|
+
description: Run Spree anywhere — any cloud, any database, from a single container to a globally distributed stack.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Spree is open source and self-hosted: you own the entire stack, end to end. There is no proprietary software in the runtime, no required third-party service, and no per-order fees. The same application runs on a $10 VPS, a managed cloud platform, a Kubernetes cluster, or a server in your own data center — and moving between them is a redeploy, not a migration.
|
|
8
|
+
|
|
9
|
+
## Run It Anywhere
|
|
10
|
+
|
|
11
|
+
Spree ships as a standard [Docker image](docker.md), which means it runs wherever containers run:
|
|
12
|
+
|
|
13
|
+
- **Public cloud** — AWS, Google Cloud, Azure, or any provider with container hosting
|
|
14
|
+
- **Platform-as-a-Service** — Render, Railway, Fly.io, and similar platforms; deploy from your repository with a Blueprint or a few clicks
|
|
15
|
+
- **VPS or bare metal** — a single machine with Docker installed is a complete production environment
|
|
16
|
+
- **Kubernetes** — the image is stateless and horizontally scalable, so it drops into any cluster
|
|
17
|
+
- **On-premise and intranet** — Spree has no phone-home dependencies, so it runs in private networks and air-gapped environments where SaaS commerce platforms simply can't
|
|
18
|
+
|
|
19
|
+
The minimum footprint is deliberately small: **one application container and one database**. Background jobs, caching, and real-time updates all run inside that container and store their data in the database — no Redis, no message broker, no extra services to provision or monitor. A store starts comfortably on 1 GB of RAM.
|
|
20
|
+
|
|
21
|
+
When you need more, every piece scales independently: add web instances behind a load balancer, split job processing into dedicated workers, add a read replica, swap the cache to Redis or Valkey, add Meilisearch for search. Each step is configuration, not rearchitecting.
|
|
22
|
+
|
|
23
|
+
## Any Database
|
|
24
|
+
|
|
25
|
+
Spree runs on all major relational databases, including the managed and serverless flavors cloud providers offer:
|
|
26
|
+
|
|
27
|
+
| Database | Managed options |
|
|
28
|
+
|----------|-----------------|
|
|
29
|
+
| **PostgreSQL** (recommended) | Amazon RDS, Aurora PostgreSQL, Google Cloud SQL, Azure Database, Neon, Supabase |
|
|
30
|
+
| **MySQL / MariaDB** | Amazon RDS, Aurora MySQL, Google Cloud SQL, Azure Database |
|
|
31
|
+
| **SQLite** | ideal for development, evaluation, and small stores |
|
|
32
|
+
|
|
33
|
+
See [Database Configuration](database.md) for details.
|
|
34
|
+
|
|
35
|
+
## Web and Worker
|
|
36
|
+
|
|
37
|
+
A Spree deployment has two kinds of work: serving requests (the **web** process) and everything that happens in the background — sending emails, processing images, delivering webhooks, importing catalogs (the **worker**).
|
|
38
|
+
|
|
39
|
+
You can run them in two modes:
|
|
40
|
+
|
|
41
|
+
- **Combined (the default)** — the web container also processes background jobs. One container is the whole application. This is how every fresh deployment starts, and it comfortably serves most stores.
|
|
42
|
+
- **Split** — when job volume grows, move background processing into a dedicated worker service. It's the same docker image with a different start command and one environment variable (`SOLID_QUEUE_IN_PUMA=false` on web) — no rebuild, no code changes. Recommended for high volume retailers, multi-tenant apps and marketplaces with a lot of vendors using our Shopify sync.
|
|
43
|
+
|
|
44
|
+
Jobs live in the database, so scaling to multiple web instances or multiple workers is safe by default — they coordinate through it. For demanding workloads, you can also [swap the job backend to Sidekiq](background_jobs.md#swapping-to-sidekiq) on Redis or Valkey. See [Background Jobs](background_jobs.md) for the full picture.
|
|
45
|
+
|
|
46
|
+
## Single-Node vs Distributed
|
|
47
|
+
|
|
48
|
+
Spree is API-first, which gives you a real choice of shape:
|
|
49
|
+
|
|
50
|
+
**Single-node** — one container serves the API, the admin dashboard, and background jobs, with one database behind it. Simplest to operate, cheapest to run, and what [create-spree-app](../create-spree-app/quickstart.md) projects deploy by default. For headless setups with a mobile app or a custom frontend, this is often all the infrastructure you ever need.
|
|
51
|
+
|
|
52
|
+
**Distributed** — because the storefront and admin talk to Spree exclusively through its APIs, each surface can be deployed and scaled on its own:
|
|
53
|
+
|
|
54
|
+
- The **API** scales horizontally behind a load balancer
|
|
55
|
+
- The **admin dashboard** is a static React app that can be served from the API container or any static host
|
|
56
|
+
- **Workers** scale independently of web traffic
|
|
57
|
+
- The **storefront** (Next.js) deploys to Vercel or any Node.js host, rendering at the edge close to your customers
|
|
58
|
+
|
|
59
|
+
You don't choose upfront. Start single-node, and split surfaces out when traffic or team structure calls for it — the API boundary is already there. Storefront is fully optional, you can use our Next.js reference implementation, or build your own with any framework, build a mobile app, or even a native desktop app. Spree is the backend for all of them.
|
|
60
|
+
|
|
61
|
+
## Storefront Deployment
|
|
62
|
+
|
|
63
|
+
The Next.js storefront is a separate application with its own deployment lifecycle — typically on Vercel, but any Node.js host or Docker environment works. It connects to your Spree API with a publishable key and can be redeployed independently of the backend.
|
|
64
|
+
|
|
65
|
+
See [Storefront Deployment](../storefront/nextjs/deployment.md) for the full guide.
|
|
66
|
+
|
|
67
|
+
## Provider Guides
|
|
68
|
+
|
|
69
|
+
Step-by-step guides for specific platforms:
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
- [AWS](aws.md) — A single EC2 instance + RDS to start, or ECS Fargate with CI/CD and auto-scaling — same image, either way.
|
|
73
|
+
|
|
74
|
+
- [Render](render.md) — One-click Blueprint: a Docker web service and managed PostgreSQL, built straight from your repository.
|
|
75
|
+
|
|
76
|
+
- **Railway (coming soon)** — A one-click Railway template is on the way.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
For any other platform, the [Docker guide](docker.md) covers building and running your project's image — which is all any container host needs.
|
|
@@ -1,75 +1,57 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Render
|
|
3
|
-
description: Deploy Spree to Render
|
|
3
|
+
description: Deploy your Spree project to Render — one Docker service, one Postgres.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
##
|
|
6
|
+
## Overview
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Every [create-spree-app](../create-spree-app/quickstart.md) project ships a ready Render Blueprint (`render.yaml` at the project root). It deploys the whole app in the [single-node topology](quickstart.md#single-node-vs-distributed): **one Docker service built straight from your repository** plus a managed PostgreSQL — nothing else:
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
- **Web** — one container running the Spree API and background jobs
|
|
11
|
+
- **PostgreSQL** — the only backing service
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
Migrations run automatically on boot. Render builds the same image `spree build --production` builds locally.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
- **Worker** — Sidekiq for background jobs
|
|
16
|
-
- **PostgreSQL** — database
|
|
17
|
-
- **Redis** — caching, jobs, Action Cable
|
|
15
|
+
> **TIP:** Just evaluating Spree? Skip self-hosting entirely and use a hosted sandbox at [spreecommerce.org](https://spreecommerce.org).
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
## Deploying
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
1. Push your create-spree-app project to GitHub
|
|
20
|
+
2. In the Render dashboard, click **New** → **Blueprint** and select your repository
|
|
21
|
+
3. Render reads `render.yaml` and creates the services. Review and click **Deploy Blueprint**.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
- [GitHub account](https://github.com)
|
|
25
|
-
|
|
26
|
-
## Custom Deployment
|
|
27
|
-
|
|
28
|
-
If you need to customize the backend (add gems, models, etc.), start from the [Spree Starter](https://github.com/spree/spree-starter) template:
|
|
29
|
-
|
|
30
|
-
1. Go to [spree/spree-starter](https://github.com/spree/spree-starter) and click **Use this template** > **Create a new repository**
|
|
31
|
-
|
|
32
|
-
2. Clone your new repository and make your changes
|
|
33
|
-
|
|
34
|
-
3. In the Render dashboard, click **New** > **Blueprint** and select your repository
|
|
35
|
-
|
|
36
|
-
4. Render reads the `render.yaml` from your repo and creates all services. Review and click **Deploy Blueprint**.
|
|
37
|
-
|
|
38
|
-
The included [`render.yaml`](https://github.com/spree/spree-starter/blob/main/render.yaml) handles:
|
|
39
|
-
- Build: `bundle install`, asset precompilation, `db:prepare`, `db:seed`
|
|
40
|
-
- Web: Puma with health check on `/up`
|
|
41
|
-
- Worker: Sidekiq with shared `SECRET_KEY_BASE`
|
|
42
|
-
- PostgreSQL 18 and Redis
|
|
23
|
+
The database is seeded on first boot. Your store is ready in a few minutes — including any customizations, since the image builds from your repository.
|
|
43
24
|
|
|
44
25
|
## After Deployment
|
|
45
26
|
|
|
46
|
-
### Admin
|
|
47
|
-
|
|
48
|
-
Access your admin panel at:
|
|
27
|
+
### Admin
|
|
49
28
|
|
|
50
29
|
```
|
|
51
|
-
https://<your-app-name>.onrender.com/admin
|
|
30
|
+
https://<your-app-name>.onrender.com/admin # admin panel
|
|
31
|
+
https://<your-app-name>.onrender.com/jobs # background jobs dashboard
|
|
52
32
|
```
|
|
53
33
|
|
|
54
|
-
Default credentials are created during
|
|
34
|
+
Default credentials are created during seeding. Change them immediately after first login.
|
|
35
|
+
|
|
36
|
+
The `/jobs` dashboard uses HTTP Basic auth: user `jobs`, with a password the Blueprint generates — read it in the Render dashboard under the web service's **Environment** tab (`MISSION_CONTROL_PASSWORD`).
|
|
55
37
|
|
|
56
38
|
### Environment Variables
|
|
57
39
|
|
|
58
|
-
Render sets `DATABASE_URL
|
|
40
|
+
Render sets `DATABASE_URL` and `SECRET_KEY_BASE` automatically from the Blueprint. For additional configuration (SMTP, file storage, Sentry, etc.), see [Environment Variables](environment_variables.md).
|
|
59
41
|
|
|
60
42
|
Generated URLs (images and attachments in API responses, email links) automatically use Render's `RENDER_EXTERNAL_HOSTNAME` (`<your-app-name>.onrender.com`). When you attach a custom domain, set [`RAILS_HOST`](environment_variables.md#urls-and-hosts) to it — it takes precedence.
|
|
61
43
|
|
|
62
|
-
##
|
|
44
|
+
## Scaling Out
|
|
63
45
|
|
|
64
|
-
The
|
|
46
|
+
The Blueprint's commented **worker** block switches to [split mode](quickstart.md#web-and-worker): background jobs move into a dedicated service — same image, no rebuild. Uncomment it and set `SOLID_QUEUE_IN_PUMA=false` on the web service so it stops running jobs.
|
|
47
|
+
|
|
48
|
+
For production workloads, we recommend:
|
|
65
49
|
|
|
66
50
|
| Service | Plan | Resources | Auto-scaling |
|
|
67
51
|
|---|---|---|---|
|
|
68
52
|
| **Web** | Pro | 4 GB RAM, 2 CPU | 1–2 instances |
|
|
69
|
-
| **Worker** | Standard | 2 GB RAM, 1 CPU | — |
|
|
53
|
+
| **Worker** (optional split) | Standard | 2 GB RAM, 1 CPU | — |
|
|
70
54
|
| **PostgreSQL** | Pro 4 GB | 4 GB RAM, 1 CPU | — |
|
|
71
|
-
| **Redis** (jobs) | Standard | 1 GB RAM | — |
|
|
72
|
-
| **Redis** (cache) | Standard | 1 GB RAM | — |
|
|
73
55
|
|
|
74
56
|
To enable auto-scaling, add this to the web service in your `render.yaml`:
|
|
75
57
|
|
|
@@ -84,6 +66,8 @@ To enable auto-scaling, add this to the web service in your `render.yaml`:
|
|
|
84
66
|
targetCPUPercent: 80
|
|
85
67
|
```
|
|
86
68
|
|
|
69
|
+
High-traffic installs can additionally swap [caching](caching.md) to a managed Redis/Valkey — the default needs no extra service.
|
|
70
|
+
|
|
87
71
|
## Next Steps
|
|
88
72
|
|
|
89
73
|
Render provides ephemeral storage — uploaded files (product images, etc.) won't persist across deploys. Set up cloud storage:
|
|
@@ -95,3 +79,5 @@ Before going to production:
|
|
|
95
79
|
- [Set environment variables](environment_variables.md) (SMTP, SSL, etc.)
|
|
96
80
|
- [Configure CDN](cdn.md)
|
|
97
81
|
- [Configure caching](caching.md)
|
|
82
|
+
|
|
83
|
+
Deploying a storefront? The Next.js storefront ships separately — typically to Vercel. See [Storefront Deployment](../storefront/nextjs/deployment.md).
|
package/package.json
CHANGED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Heroku
|
|
3
|
-
section: deployment
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Heroku
|
|
7
|
-
|
|
8
|
-
## Overview
|
|
9
|
-
|
|
10
|
-
Heroku is a Platform as a Service that makes deploying and hosting Spree applications super easy.
|
|
11
|
-
|
|
12
|
-
You should just follow [Heroku Rails 6 guide](https://devcenter.heroku.com/articles/getting-started-with-rails6).
|
|
13
|
-
|
|
14
|
-
We recommend you start and stick to Heroku if you do not have DevOps-skilled team members. [Spree Starter](https://github.com/spree/spree_starter) is pre-configured to work with Heroku out of the box.
|
|
15
|
-
|
|
16
|
-
## Dynos
|
|
17
|
-
|
|
18
|
-
[Heroku Dynos](https://www.heroku.com/dynos) are lightweight, isolated environments that provide compute and run your application.
|
|
19
|
-
|
|
20
|
-
There are 2 types of dynos:
|
|
21
|
-
|
|
22
|
-
* **Web** - for running the web interface of yuour Store Storefront, API, Admin Panel
|
|
23
|
-
* **Worker** - for running background jobs via [Active Job](https://guides.rubyonrails.org/active_job_basics.html) such as email send out, report generation, etc
|
|
24
|
-
|
|
25
|
-
### Recommended sizing
|
|
26
|
-
|
|
27
|
-
| Dynos | Staging environment | Production environment |
|
|
28
|
-
| :--- | :--- | :--- |
|
|
29
|
-
| **web** | 1 x Standard-2x | 1 x Performance-M or Performance-L |
|
|
30
|
-
| **worker** | 1 x Standard-1x | 1 x Standard-1x |
|
|
31
|
-
|
|
32
|
-
## Add-Ons
|
|
33
|
-
|
|
34
|
-
[Heroku Add-Ons](https://elements.heroku.com/addons) are tools and services for developing, extending, and operating your app.
|
|
35
|
-
|
|
36
|
-
### Recommended Add-Ons and plans
|
|
37
|
-
|
|
38
|
-
| Plan | Staging environment | Production environment |
|
|
39
|
-
| :--- | :--- | :--- |
|
|
40
|
-
| Bucketeer | Hobbyist | Micro |
|
|
41
|
-
| Edge | Hobby | Micro |
|
|
42
|
-
| Heroku Postgres | Hobby Basic | Standard-0 |
|
|
43
|
-
| Sendgrid | Free | Bronze |
|
|
44
|
-
| Sentry | Free | Small |
|
|
45
|
-
|
|
46
|
-
## Other resources
|
|
47
|
-
|
|
48
|
-
* [https://devcenter.heroku.com/categories/reference](https://devcenter.heroku.com/categories/reference)
|
|
49
|
-
* [https://devcenter.heroku.com/articles/getting-started-with-rails6](https://devcenter.heroku.com/articles/getting-started-with-rails6)
|
|
50
|
-
* [https://devcenter.heroku.com/categories/monitoring-metrics](https://devcenter.heroku.com/categories/monitoring-metrics)
|
|
51
|
-
* [https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server](https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server)
|