docker.recipes

Sylius + MySQL + Elasticsearch

advanced

Symfony-based e-commerce platform with full-text search.

Overview

Sylius is a modern, component-based e-commerce platform built on Symfony framework, designed for developers who need flexibility and customization beyond traditional e-commerce solutions like WooCommerce or Magento. Originally created in 2011, Sylius follows Domain-Driven Design principles and provides a headless commerce approach, making it ideal for businesses requiring multi-channel sales, complex product catalogs, or integration with existing enterprise systems. Unlike monolithic platforms, Sylius separates business logic into reusable components, enabling developers to build custom e-commerce experiences while maintaining core commerce functionality. This stack combines Sylius with MySQL for transactional data storage, Elasticsearch for advanced product search and filtering, NGINX as a high-performance web server, and MailHog for email testing during development. MySQL handles order processing, customer data, and inventory management with ACID compliance, while Elasticsearch provides faceted search, autocomplete, and product recommendations that scale with catalog size. NGINX serves static assets efficiently and proxies dynamic requests to the PHP application, while MailHog captures all outgoing emails for testing checkout flows, customer notifications, and marketing campaigns without sending real emails. This configuration targets mid-market retailers, B2B companies, and agencies building custom e-commerce solutions who need enterprise-grade search capabilities and reliable order processing. The combination excels for businesses with complex product catalogs (thousands of SKUs), multiple customer segments, or integration requirements with ERP, CRM, or PIM systems where off-the-shelf platforms fall short.

Key Features

  • Symfony-based component architecture enabling custom business logic and workflows
  • Full-text product search with faceted filtering, autocomplete, and relevance scoring via Elasticsearch
  • Multi-channel commerce support for web, mobile apps, and third-party marketplaces
  • Advanced promotion engine with coupon codes, discounts, and customer-specific pricing
  • MySQL InnoDB storage with transaction safety for order processing and inventory management
  • Flexible taxation system supporting multiple tax zones and complex calculation rules
  • REST API for headless commerce implementations and third-party integrations
  • Administrative panel with order management, inventory tracking, and customer service tools

Common Use Cases

  • 1B2B companies selling to multiple customer tiers with custom pricing and approval workflows
  • 2Retailers with large product catalogs requiring advanced search, filtering, and recommendation features
  • 3Agencies developing custom e-commerce solutions for clients with specific business requirements
  • 4Multi-brand retailers managing separate storefronts with shared inventory and customer data
  • 5Marketplace operators connecting multiple vendors with centralized order and payment processing
  • 6International businesses requiring multi-currency support and localized tax calculations
  • 7Companies migrating from legacy e-commerce systems while maintaining custom integrations

Prerequisites

  • Docker and Docker Compose installed with minimum 6GB available RAM for all services
  • Ports 80, 8025 available for web interface and MailHog email testing interface
  • Basic understanding of Symfony framework and PHP application deployment
  • Familiarity with Elasticsearch indexing concepts for product catalog management
  • Knowledge of NGINX configuration for SSL termination and performance tuning in production
  • MySQL administration skills for backup strategies and performance optimization

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 sylius:
3 image: sylius/sylius:latest
4 environment:
5 - APP_ENV=prod
6 - APP_SECRET=${APP_SECRET}
7 - DATABASE_URL=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@mysql:3306/sylius
8 - ELASTICSEARCH_URL=http://elasticsearch:9200
9 - MAILER_DSN=smtp://mailhog:1025
10 volumes:
11 - sylius-public:/app/public/media
12 depends_on:
13 - mysql
14 - elasticsearch
15 networks:
16 - sylius-network
17 restart: unless-stopped
18
19 nginx:
20 image: nginx:alpine
21 volumes:
22 - ./nginx.conf:/etc/nginx/nginx.conf:ro
23 - sylius-public:/app/public:ro
24 ports:
25 - "80:80"
26 depends_on:
27 - sylius
28 networks:
29 - sylius-network
30 restart: unless-stopped
31
32 mysql:
33 image: mysql:8.0
34 environment:
35 - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
36 - MYSQL_DATABASE=sylius
37 - MYSQL_USER=${MYSQL_USER}
38 - MYSQL_PASSWORD=${MYSQL_PASSWORD}
39 volumes:
40 - mysql-data:/var/lib/mysql
41 networks:
42 - sylius-network
43 restart: unless-stopped
44
45 elasticsearch:
46 image: elasticsearch:7.17.10
47 environment:
48 - discovery.type=single-node
49 - ES_JAVA_OPTS=-Xms512m -Xmx512m
50 volumes:
51 - es-data:/usr/share/elasticsearch/data
52 networks:
53 - sylius-network
54 restart: unless-stopped
55
56 mailhog:
57 image: mailhog/mailhog
58 ports:
59 - "8025:8025"
60 networks:
61 - sylius-network
62 restart: unless-stopped
63
64volumes:
65 sylius-public:
66 mysql-data:
67 es-data:
68
69networks:
70 sylius-network:
71 driver: bridge

.env Template

.env
1# Sylius
2APP_SECRET=your-app-secret-change-this
3MYSQL_ROOT_PASSWORD=secure_root_password
4MYSQL_USER=sylius
5MYSQL_PASSWORD=secure_mysql_password

Usage Notes

  1. 1Store at http://localhost
  2. 2Admin at http://localhost/admin
  3. 3MailHog at http://localhost:8025
  4. 4Install fixtures: bin/console sylius:fixtures:load
  5. 5Elasticsearch for product search

Individual Services(5 services)

Copy individual services to mix and match with your existing compose files.

sylius
sylius:
  image: sylius/sylius:latest
  environment:
    - APP_ENV=prod
    - APP_SECRET=${APP_SECRET}
    - DATABASE_URL=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@mysql:3306/sylius
    - ELASTICSEARCH_URL=http://elasticsearch:9200
    - MAILER_DSN=smtp://mailhog:1025
  volumes:
    - sylius-public:/app/public/media
  depends_on:
    - mysql
    - elasticsearch
  networks:
    - sylius-network
  restart: unless-stopped
nginx
nginx:
  image: nginx:alpine
  volumes:
    - ./nginx.conf:/etc/nginx/nginx.conf:ro
    - sylius-public:/app/public:ro
  ports:
    - "80:80"
  depends_on:
    - sylius
  networks:
    - sylius-network
  restart: unless-stopped
mysql
mysql:
  image: mysql:8.0
  environment:
    - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
    - MYSQL_DATABASE=sylius
    - MYSQL_USER=${MYSQL_USER}
    - MYSQL_PASSWORD=${MYSQL_PASSWORD}
  volumes:
    - mysql-data:/var/lib/mysql
  networks:
    - sylius-network
  restart: unless-stopped
elasticsearch
elasticsearch:
  image: elasticsearch:7.17.10
  environment:
    - discovery.type=single-node
    - ES_JAVA_OPTS=-Xms512m -Xmx512m
  volumes:
    - es-data:/usr/share/elasticsearch/data
  networks:
    - sylius-network
  restart: unless-stopped
mailhog
mailhog:
  image: mailhog/mailhog
  ports:
    - "8025:8025"
  networks:
    - sylius-network
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 sylius:
5 image: sylius/sylius:latest
6 environment:
7 - APP_ENV=prod
8 - APP_SECRET=${APP_SECRET}
9 - DATABASE_URL=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@mysql:3306/sylius
10 - ELASTICSEARCH_URL=http://elasticsearch:9200
11 - MAILER_DSN=smtp://mailhog:1025
12 volumes:
13 - sylius-public:/app/public/media
14 depends_on:
15 - mysql
16 - elasticsearch
17 networks:
18 - sylius-network
19 restart: unless-stopped
20
21 nginx:
22 image: nginx:alpine
23 volumes:
24 - ./nginx.conf:/etc/nginx/nginx.conf:ro
25 - sylius-public:/app/public:ro
26 ports:
27 - "80:80"
28 depends_on:
29 - sylius
30 networks:
31 - sylius-network
32 restart: unless-stopped
33
34 mysql:
35 image: mysql:8.0
36 environment:
37 - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
38 - MYSQL_DATABASE=sylius
39 - MYSQL_USER=${MYSQL_USER}
40 - MYSQL_PASSWORD=${MYSQL_PASSWORD}
41 volumes:
42 - mysql-data:/var/lib/mysql
43 networks:
44 - sylius-network
45 restart: unless-stopped
46
47 elasticsearch:
48 image: elasticsearch:7.17.10
49 environment:
50 - discovery.type=single-node
51 - ES_JAVA_OPTS=-Xms512m -Xmx512m
52 volumes:
53 - es-data:/usr/share/elasticsearch/data
54 networks:
55 - sylius-network
56 restart: unless-stopped
57
58 mailhog:
59 image: mailhog/mailhog
60 ports:
61 - "8025:8025"
62 networks:
63 - sylius-network
64 restart: unless-stopped
65
66volumes:
67 sylius-public:
68 mysql-data:
69 es-data:
70
71networks:
72 sylius-network:
73 driver: bridge
74EOF
75
76# 2. Create the .env file
77cat > .env << 'EOF'
78# Sylius
79APP_SECRET=your-app-secret-change-this
80MYSQL_ROOT_PASSWORD=secure_root_password
81MYSQL_USER=sylius
82MYSQL_PASSWORD=secure_mysql_password
83EOF
84
85# 3. Start the services
86docker compose up -d
87
88# 4. View logs
89docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/sylius-complete/run | bash

Troubleshooting

  • Elasticsearch cluster health RED status: Increase Docker memory limit to minimum 4GB and set ES_JAVA_OPTS=-Xms1g -Xmx1g
  • Sylius installation fails with memory errors: Add PHP memory_limit=2G environment variable and increase container resources
  • Product search returns no results: Run bin/console fos:elastica:populate to reindex product catalog in Elasticsearch
  • MySQL connection refused errors: Verify MYSQL_USER and MYSQL_PASSWORD environment variables match between services
  • Static assets not loading: Check NGINX volume mounts and ensure sylius-public volume contains uploaded media files
  • Email notifications not captured: Verify MAILER_DSN points to mailhog:1025 and check MailHog interface at localhost:8025

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space