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.

Update docker-compose template: Sidekiq + Redis + Mailpit

Damian Legawiec348c562b395d
diff --git a/packages/create-spree-app/src/constants.ts b/packages/create-spree-app/src/constants.ts
index b63764cbd3..c8245b6d86 100644
--- a/packages/create-spree-app/src/constants.ts
+++ b/packages/create-spree-app/src/constants.ts
@@ -3,9 +3,6 @@ export const SPREE_VERSION_TAG = 'latest'
export const DEFAULT_SPREE_PORT = 3000
export const STOREFRONT_PORT = 3001
-export const HEALTH_CHECK_INTERVAL_MS = 3000
-export const HEALTH_CHECK_TIMEOUT_MS = 120_000
-
export const STOREFRONT_REPO = 'https://github.com/spree/nextjs-starter-spree.git'
export const DEFAULT_ADMIN_EMAIL = '[email protected]'
diff --git a/packages/create-spree-app/src/templates/docker-compose.ts b/packages/create-spree-app/src/templates/docker-compose.ts
index 80f45b84e6..8972d674f9 100644
--- a/packages/create-spree-app/src/templates/docker-compose.ts
+++ b/packages/create-spree-app/src/templates/docker-compose.ts
@@ -1,7 +1,25 @@
import { SPREE_IMAGE, SPREE_VERSION_TAG } from '../constants.js'
export function dockerComposeContent(_port: number): string {
- return `services:
+ return `x-app: &app
+ image: ${SPREE_IMAGE}:${SPREE_VERSION_TAG}
+ depends_on:
+ postgres:
+ condition: service_healthy
+ redis:
+ condition: service_healthy
+ env_file: .env
+ environment: &app-env
+ DATABASE_HOST: postgres
+ REDIS_URL: redis://redis:6379/0
+ SMTP_HOST: mailpit
+ SMTP_PORT: 1025
+ RAILS_ENV: production
+ RAILS_FORCE_SSL: "false"
+ RAILS_ASSUME_SSL: "false"
+ RAILS_LOG_TO_STDOUT: "true"
+
+services:
postgres:
image: postgres:17-alpine
environment:
@@ -14,21 +32,24 @@ export function dockerComposeContent(_port: number): string {
timeout: 5s
retries: 5
+ redis:
+ image: redis:7-alpine
+ volumes:
+ - redis_data:/data
+ healthcheck:
+ test: redis-cli ping
+ interval: 5s
+ timeout: 5s
+ retries: 5
+
+ mailpit:
+ image: axllent/mailpit
+ ports:
+ - "8025:8025"
+ - "1025:1025"
+
web:
- image: ${SPREE_IMAGE}:${SPREE_VERSION_TAG}
- depends_on:
- postgres:
- condition: service_healthy
- env_file: .env
- environment:
- DATABASE_URL: postgres://postgres@postgres:5432/spree_production
- CACHE_DATABASE_URL: postgres://postgres@postgres:5432/spree_production_cache
- QUEUE_DATABASE_URL: postgres://postgres@postgres:5432/spree_production_queue
- CABLE_DATABASE_URL: postgres://postgres@postgres:5432/spree_production_cable
- RAILS_ENV: production
- RAILS_FORCE_SSL: "false"
- RAILS_ASSUME_SSL: "false"
- RAILS_LOG_TO_STDOUT: "true"
+ <<: *app
ports:
- "\${SPREE_PORT:-3000}:3000"
healthcheck:
@@ -39,21 +60,11 @@ export function dockerComposeContent(_port: number): string {
start_period: 30s
worker:
- image: ${SPREE_IMAGE}:${SPREE_VERSION_TAG}
- depends_on:
- web:
- condition: service_healthy
- env_file: .env
- environment:
- DATABASE_URL: postgres://postgres@postgres:5432/spree_production
- CACHE_DATABASE_URL: postgres://postgres@postgres:5432/spree_production_cache
- QUEUE_DATABASE_URL: postgres://postgres@postgres:5432/spree_production_queue
- CABLE_DATABASE_URL: postgres://postgres@postgres:5432/spree_production_cable
- RAILS_ENV: production
- RAILS_LOG_TO_STDOUT: "true"
- command: bin/jobs
+ <<: *app
+ command: bundle exec sidekiq
volumes:
postgres_data:
+ redis_data:
`
}
diff --git a/packages/create-spree-app/src/templates/package-json.ts b/packages/create-spree-app/src/templates/package-json.ts
index 8c33fa3e4f..e778c40748 100644
--- a/packages/create-spree-app/src/templates/package-json.ts
+++ b/packages/create-spree-app/src/templates/package-json.ts
@@ -14,7 +14,7 @@ export function rootPackageJsonContent(name: string): string {
console: 'spree console',
},
dependencies: {
- '@spree/cli': '^2.0.0-beta',
+ '@spree/cli': '2.0.0-beta',
},
}
diff --git a/packages/create-spree-app/src/templates/readme.ts b/packages/create-spree-app/src/templates/readme.ts
index f0fadb522d..1b032206fe 100644
--- a/packages/create-spree-app/src/templates/readme.ts
+++ b/packages/create-spree-app/src/templates/readme.ts
@@ -24,6 +24,7 @@ Wait for the services to be healthy, then open:
- Email: \`${DEFAULT_ADMIN_EMAIL}\`
- Password: \`${DEFAULT_ADMIN_PASSWORD}\`
- **Store API:** http://localhost:${port}/api/v3/store
+- **Mailpit (email inbox):** http://localhost:8025
`
if (hasStorefront) {
diff --git a/packages/create-spree-app/tests/templates.test.ts b/packages/create-spree-app/tests/templates.test.ts
index 4e1a497711..f21b17a90d 100644
--- a/packages/create-spree-app/tests/templates.test.ts
+++ b/packages/create-spree-app/tests/templates.test.ts
@@ -20,22 +20,26 @@ describe('dockerComposeContent', () => {
expect(content).toContain('curl -f http://localhost:3000/up')
})
- it('includes worker service with bin/jobs command', () => {
- expect(content).toContain('command: bin/jobs')
+ it('includes worker service with sidekiq command', () => {
+ expect(content).toContain('command: bundle exec sidekiq')
})
it('includes volume definition', () => {
expect(content).toContain('postgres_data:')
})
- it('uses DATABASE_URL pointing to postgres service', () => {
- expect(content).toContain('DATABASE_URL: postgres://postgres@postgres:5432/spree_production')
+ it('uses DATABASE_HOST pointing to postgres service', () => {
+ expect(content).toContain('DATABASE_HOST: postgres')
})
- it('sets separate URLs for cache, queue, and cable databases', () => {
- expect(content).toContain('CACHE_DATABASE_URL: postgres://postgres@postgres:5432/spree_production_cache')
- expect(content).toContain('QUEUE_DATABASE_URL: postgres://postgres@postgres:5432/spree_production_queue')
- expect(content).toContain('CABLE_DATABASE_URL: postgres://postgres@postgres:5432/spree_production_cable')
+ it('includes redis service and REDIS_URL', () => {
+ expect(content).toContain('redis:7-alpine')
+ expect(content).toContain('REDIS_URL: redis://redis:6379/0')
+ })
+
+ it('includes mailpit service for local email', () => {
+ expect(content).toContain('axllent/mailpit')
+ expect(content).toContain('SMTP_HOST: mailpit')
})
it('uses production environment with SSL disabled', () => {