# Shopware 6 + MySQL + Elasticsearch

> Enterprise e-commerce platform with advanced features.

- Category: E-Commerce & Business
- Difficulty: advanced
- Components: shopware, mysql, elasticsearch, redis, nginx
- Tags: shopware, ecommerce, enterprise, php, elasticsearch
- Source: https://docker.recipes/ecommerce/shopware-complete

## Overview

Shopware 6 is a German-built open-source e-commerce platform designed for enterprise-grade online stores. Originally launched in 2000 and completely rebuilt from the ground up, Shopware 6 offers advanced features like headless commerce, progressive web app capabilities, and extensive API-first architecture. It competes directly with platforms like Magento and WooCommerce but focuses on providing superior user experience for both merchants and customers with its modern Vue.js-based administration interface and Symfony framework foundation.

This stack combines Shopware 6 with MySQL for transactional data storage, Elasticsearch for product search and catalog indexing, Redis for session management and caching, and NGINX as a high-performance web server. MySQL handles all product data, customer information, and order processing with ACID compliance, while Elasticsearch powers the advanced search functionality that modern e-commerce demands. Redis accelerates page load times by caching frequently accessed data and managing user sessions, and NGINX serves static assets efficiently while proxying dynamic requests to Shopware.

This configuration is ideal for medium to large online retailers who need scalable search capabilities, fast response times, and enterprise-grade reliability. E-commerce agencies, digital marketing companies, and businesses processing thousands of products with complex filtering requirements will benefit most from this stack. The combination provides the performance needed for high-traffic sales events, complex product catalogs, and multi-language storefronts that require sophisticated search and filtering capabilities.

## Features

- Advanced product search with Elasticsearch faceted filtering and auto-suggestions
- MySQL 8.0 InnoDB storage engine with JSON field support for flexible product attributes
- Redis-powered shopping cart persistence and user session management
- Shopware 6 Sales Channel API for headless commerce and mobile app integration
- NGINX FastCGI caching with 2-hour TTL for improved page load performance
- Elasticsearch aggregations for real-time inventory filtering and category browsing
- Shopware Administration interface with Vue.js for modern store management
- Multi-language and multi-currency support with localized search indexing

## Use cases

- Fashion retailers with complex product variations, sizes, and color filtering
- B2B wholesale platforms requiring customer-specific pricing and catalog access
- Multi-brand online stores managing separate inventories and search indexes
- Digital agencies developing custom e-commerce solutions for enterprise clients
- Retailers migrating from Magento or WooCommerce seeking better performance
- Online marketplaces with thousands of products requiring fast search capabilities
- International e-commerce sites needing multi-language product search

## Prerequisites

- Minimum 4GB RAM (2GB for Elasticsearch, 1GB for MySQL, 1GB for Shopware)
- Docker Engine 20.10+ and Docker Compose 2.0+ installed
- Port 80 available for NGINX web server access
- Basic understanding of Shopware 6 administration and store configuration
- Familiarity with MySQL database management for backup and maintenance
- Knowledge of Elasticsearch indexing concepts for search optimization

## docker-compose.yml

```yaml
services:
  shopware:
    image: shyim/shopware:latest
    environment:
      - APP_ENV=prod
      - APP_SECRET=${APP_SECRET}
      - DATABASE_URL=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@mysql:3306/shopware
      - ELASTICSEARCH_HOSTS=elasticsearch:9200
      - REDIS_HOST=redis
      - SHOPWARE_HTTP_CACHE_ENABLED=1
      - SHOPWARE_HTTP_DEFAULT_TTL=7200
    volumes:
      - shopware-data:/var/www/html
    depends_on:
      - mysql
      - elasticsearch
      - redis
    networks:
      - shopware-network
    restart: unless-stopped

  nginx:
    image: nginx:alpine
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - shopware-data:/var/www/html:ro
    ports:
      - "80:80"
    depends_on:
      - shopware
    networks:
      - shopware-network
    restart: unless-stopped

  mysql:
    image: mysql:8.0
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=shopware
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    volumes:
      - mysql-data:/var/lib/mysql
    networks:
      - shopware-network
    restart: unless-stopped

  elasticsearch:
    image: elasticsearch:7.17.10
    environment:
      - discovery.type=single-node
      - ES_JAVA_OPTS=-Xms512m -Xmx512m
    volumes:
      - es-data:/usr/share/elasticsearch/data
    networks:
      - shopware-network
    restart: unless-stopped

  redis:
    image: redis:alpine
    volumes:
      - redis-data:/data
    networks:
      - shopware-network
    restart: unless-stopped

volumes:
  shopware-data:
  mysql-data:
  es-data:
  redis-data:

networks:
  shopware-network:
    driver: bridge
```

## .env

```bash
# Shopware 6
APP_SECRET=your-app-secret-change-this
MYSQL_ROOT_PASSWORD=secure_root_password
MYSQL_USER=shopware
MYSQL_PASSWORD=secure_mysql_password
```

## Usage notes

- Store at http://localhost
- Admin at http://localhost/admin
- Default admin: admin / shopware
- Elasticsearch for search
- Redis for caching

## Troubleshooting

- Elasticsearch circuit_breaker_exception: Increase ES_JAVA_OPTS memory allocation beyond -Xms512m -Xmx512m
- Shopware installation wizard shows database connection error: Verify MYSQL_USER and MYSQL_PASSWORD environment variables match
- Product search returns no results: Check if Elasticsearch indexes are built by running bin/console es:index:populate in Shopware container
- 502 Bad Gateway from NGINX: Ensure Shopware container is fully started before NGINX attempts proxying
- Redis connection timeout errors: Verify REDIS_HOST environment variable points to correct service name 'redis'
- MySQL access denied errors: Wait for MySQL initialization to complete before starting dependent services

