Skip to content

Commit b80aea8

Browse files
Added meilisearch and docker compose files
1 parent f36836f commit b80aea8

File tree

7 files changed

+191
-0
lines changed

7 files changed

+191
-0
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,9 @@ PORT=3000
4040
# RAILS_ENV=production
4141
# RAILS_LOG_LEVEL=info
4242

43+
# Search
44+
# MEILISEARCH_URL=
45+
# MEILISEARCH_API_KEY=
46+
4347
# Spree core development — set to path of spree monorepo to use local gems
4448
# SPREE_PATH=../spree

Brewfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
brew 'ruby' # see .ruby-version for required version
44
brew 'postgresql@18'
55
brew 'redis'
6+
brew 'meilisearch'
67
brew 'vips'
78
brew 'overmind'

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ gem 'tailwindcss-rails'
5454
gem 'thruster', require: false
5555
gem 'turbo-rails'
5656

57+
# Search
58+
gem 'meilisearch', '>= 0.28'
59+
5760
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
5861
gem 'tzinfo-data', platforms: %i[windows jruby]
5962

Gemfile.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ GEM
269269
reline
270270
hightop (0.6.0)
271271
activesupport (>= 7.1)
272+
httparty (0.24.2)
273+
csv
274+
mini_mime (>= 1.0.0)
275+
multi_xml (>= 0.5.2)
272276
i18n (1.14.8)
273277
concurrent-ruby (~> 1.0)
274278
i18n-tasks (1.1.2)
@@ -359,6 +363,8 @@ GEM
359363
matrix (0.4.3)
360364
mcp (0.8.0)
361365
json-schema (>= 4.1)
366+
meilisearch (0.33.0)
367+
httparty (~> 0.24)
362368
method_source (1.1.0)
363369
metrics (0.15.0)
364370
mini_magick (5.3.1)
@@ -381,6 +387,8 @@ GEM
381387
money (6.19.0)
382388
i18n (>= 0.6.4, <= 2)
383389
msgpack (1.8.0)
390+
multi_xml (0.8.1)
391+
bigdecimal (>= 3.1, < 5)
384392
name_of_person (1.1.3)
385393
activesupport (>= 5.2.0)
386394
net-http (0.9.1)
@@ -848,6 +856,7 @@ DEPENDENCIES
848856
letter_opener
849857
listen
850858
lograge
859+
meilisearch (>= 0.28)
851860
pg (~> 1.1)
852861
propshaft
853862
puma (>= 5.0)
@@ -967,6 +976,7 @@ CHECKSUMS
967976
groupdate (6.7.0) sha256=beaa8d5bf3856814681914a1d4a20e77436a2214b85d0017dc2ea5c355fb6777
968977
highline (3.1.2) sha256=67cbd34d19f6ef11a7ee1d82ffab5d36dfd5b3be861f450fc1716c7125f4bb4a
969978
hightop (0.6.0) sha256=d3799d2232e4d0bc69bfd940e49832d66bcf18b7098be252a4fd65f1eb29b778
979+
httparty (0.24.2) sha256=8fca6a54aa0c4aa4303a0fd33e5e2156175d6a5334f714263b458abd7fda9c38
970980
i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5
971981
i18n-tasks (1.1.2) sha256=4dcfba49e52a623f30661cb316cb80d84fbba5cb8c6d88ef5e02545fffa3637a
972982
i18n_data (1.1.0) sha256=fb7ae43bd03ec4dc2e6e62e726aac05aa868c170ba1444c056e2ab0d872bb2ed
@@ -1001,6 +1011,7 @@ CHECKSUMS
10011011
marcel (1.1.0) sha256=fdcfcfa33cc52e93c4308d40e4090a5d4ea279e160a7f6af988260fa970e0bee
10021012
matrix (0.4.3) sha256=a0d5ab7ddcc1973ff690ab361b67f359acbb16958d1dc072b8b956a286564c5b
10031013
mcp (0.8.0) sha256=ae8bd146bb8e168852866fd26f805f52744f6326afb3211e073f78a95e0c34fb
1014+
meilisearch (0.33.0) sha256=a5d3c3f28cdc4394ee4f0f390efe158650f99cfb390fd073f44fc780a2aa41e2
10041015
method_source (1.1.0) sha256=181301c9c45b731b4769bc81e8860e72f9161ad7d66dd99103c9ab84f560f5c5
10051016
metrics (0.15.0) sha256=61ded5bac95118e995b1bc9ed4a5f19bc9814928a312a85b200abbdac9039072
10061017
mini_magick (5.3.1) sha256=29395dfd76badcabb6403ee5aff6f681e867074f8f28ce08d78661e9e4a351c4
@@ -1012,6 +1023,7 @@ CHECKSUMS
10121023
monetize (1.13.0) sha256=0c1f8ae28aa21bbf1a6d014138d9bb0a5ce756c1a99b8b7f7d409c258b01d3b3
10131024
money (6.19.0) sha256=ec936fa1e42f2783719241ed9fd52725d0efa628f928feea1eb5c37d5de7daf3
10141025
msgpack (1.8.0) sha256=e64ce0212000d016809f5048b48eb3a65ffb169db22238fb4b72472fecb2d732
1026+
multi_xml (0.8.1) sha256=addba0290bac34e9088bfe73dc4878530297a82a7bbd66cb44dcd0a4b86edf5a
10151027
name_of_person (1.1.3) sha256=e12291250987ef79c413314f698f15d53e7a602c42231de99c276ef9585bc18c
10161028
net-http (0.9.1) sha256=25ba0b67c63e89df626ed8fac771d0ad24ad151a858af2cc8e6a716ca4336996
10171029
net-imap (0.6.3) sha256=9bab75f876596d09ee7bf911a291da478e0cd6badc54dfb82874855ccc82f2ad

config/initializers/spree.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
Spree.user_class = 'Spree::User'
6363
Spree.admin_user_class = 'Spree::AdminUser'
6464

65+
if ENV['MEILISEARCH_URL'].present?
66+
Spree.search_provider = 'Spree::SearchProvider::Meilisearch'
67+
end
68+
6569
Rails.application.config.to_prepare do
6670
require_dependency 'spree/authentication_helpers'
6771
end

docker-compose.dev.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Development: docker compose -f docker-compose.dev.yml up --build
2+
# Builds from the local Dockerfile — use after customizing gems or app code.
3+
x-app: &app
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
depends_on:
8+
postgres:
9+
condition: service_healthy
10+
redis:
11+
condition: service_healthy
12+
meilisearch:
13+
condition: service_healthy
14+
env_file: .env
15+
environment: &app-env
16+
DATABASE_URL: postgres://postgres@postgres:5432/spree_production
17+
REDIS_URL: redis://redis:6379/0
18+
SECRET_KEY_BASE: ${SECRET_KEY_BASE}
19+
RAILS_FORCE_SSL: "false"
20+
RAILS_ASSUME_SSL: "false"
21+
MEILISEARCH_URL: http://meilisearch:7700
22+
SMTP_HOST: mailpit
23+
SMTP_PORT: "1025"
24+
25+
services:
26+
postgres:
27+
image: postgres:18-alpine
28+
environment:
29+
POSTGRES_HOST_AUTH_METHOD: trust
30+
volumes:
31+
- postgres_data:/var/lib/postgresql/data
32+
healthcheck:
33+
test: pg_isready -U postgres
34+
interval: 5s
35+
timeout: 5s
36+
retries: 5
37+
38+
redis:
39+
image: redis:7-alpine
40+
volumes:
41+
- redis_data:/data
42+
healthcheck:
43+
test: redis-cli ping
44+
interval: 5s
45+
timeout: 5s
46+
retries: 5
47+
48+
meilisearch:
49+
image: getmeili/meilisearch:latest
50+
volumes:
51+
- meilisearch_data:/meili_data
52+
ports:
53+
- "7700:7700"
54+
healthcheck:
55+
test: curl -f http://localhost:7700/health || exit 1
56+
interval: 5s
57+
timeout: 5s
58+
retries: 5
59+
60+
mailpit:
61+
image: axllent/mailpit
62+
ports:
63+
- "8025:8025"
64+
- "1025:1025"
65+
66+
web:
67+
<<: *app
68+
ports:
69+
- "${SPREE_PORT:-3000}:3000"
70+
healthcheck:
71+
test: curl -f http://localhost:3000/up || exit 1
72+
interval: 10s
73+
timeout: 5s
74+
retries: 10
75+
start_period: 30s
76+
77+
worker:
78+
<<: *app
79+
command: bundle exec sidekiq
80+
81+
volumes:
82+
postgres_data:
83+
redis_data:
84+
meilisearch_data:

docker-compose.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Quick-start: docker compose up
2+
# Uses prebuilt Spree image — no local build needed.
3+
# To customize the backend, run: docker compose -f docker-compose.dev.yml up
4+
x-app: &app
5+
image: ghcr.io/spree/spree:${SPREE_VERSION_TAG:-latest}
6+
depends_on:
7+
postgres:
8+
condition: service_healthy
9+
redis:
10+
condition: service_healthy
11+
meilisearch:
12+
condition: service_healthy
13+
env_file: .env
14+
environment: &app-env
15+
DATABASE_URL: postgres://postgres@postgres:5432/spree_production
16+
REDIS_URL: redis://redis:6379/0
17+
SECRET_KEY_BASE: ${SECRET_KEY_BASE}
18+
RAILS_FORCE_SSL: "false"
19+
RAILS_ASSUME_SSL: "false"
20+
MEILISEARCH_URL: http://meilisearch:7700
21+
SMTP_HOST: mailpit
22+
SMTP_PORT: "1025"
23+
24+
services:
25+
postgres:
26+
image: postgres:18-alpine
27+
environment:
28+
POSTGRES_HOST_AUTH_METHOD: trust
29+
volumes:
30+
- postgres_data:/var/lib/postgresql/data
31+
healthcheck:
32+
test: pg_isready -U postgres
33+
interval: 5s
34+
timeout: 5s
35+
retries: 5
36+
37+
redis:
38+
image: redis:7-alpine
39+
volumes:
40+
- redis_data:/data
41+
healthcheck:
42+
test: redis-cli ping
43+
interval: 5s
44+
timeout: 5s
45+
retries: 5
46+
47+
meilisearch:
48+
image: getmeili/meilisearch:latest
49+
volumes:
50+
- meilisearch_data:/meili_data
51+
ports:
52+
- "7700:7700"
53+
healthcheck:
54+
test: curl -f http://localhost:7700/health || exit 1
55+
interval: 5s
56+
timeout: 5s
57+
retries: 5
58+
59+
mailpit:
60+
image: axllent/mailpit
61+
ports:
62+
- "8025:8025"
63+
- "1025:1025"
64+
65+
web:
66+
<<: *app
67+
ports:
68+
- "${SPREE_PORT:-3000}:3000"
69+
healthcheck:
70+
test: curl -f http://localhost:3000/up || exit 1
71+
interval: 10s
72+
timeout: 5s
73+
retries: 10
74+
start_period: 30s
75+
76+
worker:
77+
<<: *app
78+
command: bundle exec sidekiq
79+
80+
volumes:
81+
postgres_data:
82+
redis_data:
83+
meilisearch_data:

0 commit comments

Comments
 (0)