Sylius is an open-source, headless e-commerce platform built on the Symfony framework.
At the time of writing, the latest stable version of Sylius is 2.1
This guide walks you through the step-by-step process of deploying Sylius for production using Docker. Using Docker ensures your e-commerce platform is secure, scalable, and maintainable.
The deployment process consists of two main phases: building the Docker images and running the containers.
- Step 1: Build Images: Use the provided
Dockerfileanddocker-compose.ymlto create the Sylius Docker image. - Step 2: Run Containers: Start the Sylius application using Docker Compose, configuring the necessary environment variables for a production environment.
Step 1: Build Images ➥
mkdir sylius/build
cd sylius/build
Clone the official Sylius Standard Edition:
git clone https://github.com/Sylius/Sylius-Standard sylius-git
Create the following files with the contents provided below:
file: sylius/build/Dockerfile ➥
###############################################
# 1) PHP Build Stage (Composer + Sylius setup)
###############################################
FROM php:8.3-fpm AS php_build
# System packages
RUN apt-get update && apt-get install -y \
git unzip zip nodejs npm \
libicu-dev libjpeg-dev libpng-dev libfreetype6-dev \
libzip-dev libsodium-dev libxml2-dev libpq-dev \
&& corepack enable
# PHP Extensions
RUN docker-php-ext-configure gd \
--with-freetype \
--with-jpeg && \
docker-php-ext-install \
gd \
exif \
fileinfo \
intl \
sodium \
pdo_pgsql \
zip
# Install Composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www/sylius
# Copy entire project first
COPY ./sylius-git ./
# Install vendors (Production mode)
RUN composer install \
--no-interaction --no-scripts
# Build Sylius assets (Yarn)
RUN yarn install && yarn build
###############################################
# 2) Production Runtime Image
###############################################
FROM php:8.3-fpm AS runtime
# System packages
RUN apt-get update && apt-get install -y \
libicu-dev libjpeg-dev libpng-dev libfreetype6-dev \
libzip-dev libsodium-dev libxml2-dev libpq-dev
# PHP Extensions (same as build stage)
RUN docker-php-ext-configure gd \
--with-freetype \
--with-jpeg && \
docker-php-ext-install \
gd \
exif \
fileinfo \
intl \
sodium \
pdo_pgsql \
zip
# Working directory
WORKDIR /var/www/sylius
# Copy built application from previous stage
COPY --from=php_build /var/www/sylius ./
# Permissions (safe in container)
RUN mkdir -p var/cache var/log && chmod -R 777 var
EXPOSE 9000
CMD ["php-fpm"]
file: sylius/build/docker-compose.yml ➥
services:
sylius:
build:
context: .
dockerfile: Dockerfile
image: sylius
container_name: sylius-prod
Build the Production Docker Image ➥
Now we have the files/dirs in below structure
sylius/
└── build/
├── docker-compose.yml
├── Dockerfile
└── sylius-git/
cd sylius/build
sudo docker compose build
This command will build the Docker image for Sylius.
Upon a successful build, you can verify the image using the command sudo docker images.
Step 2: Run the Docker Container ➥
Now that the Docker images are built, let’s add Nginx and PostgreSQL and connect them with Sylius to form a complete setup.
sylius/
├── build/
│ ├── docker-compose.yml
│ ├── Dockerfile
│ └── sylius-git/
└── run/
├── docker-compose.yml
└── nginx.conf
To do this, create a new docker-compose.yml file at sylius/run/docker-compose.yml and nginx.conf file at sylius/run/nginx.conf with the following content:
file: sylius/run/docker-compose.yml ➥
services:
sylius-postgres18:
image: postgres:18-alpine
container_name: sylius-db
environment:
POSTGRES_DB: sylius
POSTGRES_USER: sylius
POSTGRES_PASSWORD: sylius$1258pass
TZ: Asia/Kolkata
logging:
driver: none
restart: unless-stopped
volumes:
- /server/storage/sylius/db:/var/lib/postgresql/data
networks:
- sylius-internal
sylius:
image: sylius:latest
container_name: sylius
depends_on:
- sylius-postgres18
environment:
DATABASE_URL: postgresql://sylius:sylius$1258pass@sylius-postgres18:5432/sylius?serverVersion=18&charset=utf8
TZ: Asia/Kolkata
APP_ENV: prod
APP_DEBUG: 0
APP_SECRET: ad3e69deed03d8a7c1b9703d70bee1626781b35b1cbf8bffd22055963799f69b
restart: unless-stopped
volumes:
- /server/storage/sylius/public:/var/www/sylius/public
- /server/storage/sylius/var:/var/www/sylius/var
networks:
- proxy
- sylius-internal
sylius-nginx:
image: nginx:alpine
container_name: sylius-webserver
depends_on:
- sylius
ports:
- "8080:80"
volumes:
- /server/storage/sylius/public:/var/www/sylius/public:ro
- ./nginx.conf:/etc/nginx/conf.d/default.conf
networks:
- proxy
- sylius-internal
restart: unless-stopped
networks:
proxy:
external: true
sylius-internal:
driver: bridge
file: sylius/run/nginx.conf ➥
server {
listen 80;
server_name _;
root /var/www/sylius/public;
index index.php;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass sylius:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
client_max_body_size 50M;
}
Ensure you configure the following in your environment or compose file:
- Use strong database credentials and restrict access (use
openssl rand -hex 32). - Persist data volumes for database and Sylius media.
Now bring up our Sylius stack:
cd sylius/run
sudo docker compose up -d
Step 3: Install and Initialize Sylius ➥
Now we have our docker container running. We can install and initialize Sylius using the below command
sudo docker compose exec sylius php bin/console sylius:install -s default -n
## Or below command if you face any memory issue
sudo docker compose exec sylius php -d memory_limit=1G bin/console sylius:install -s default -n
$ sudo docker compose exec sylius php -d memory_limit=1G bin/console sylius:install -s default -n
Installing Sylius...
,
,;:,
`;;;.:`
`::;` :`
:::` ` .'++: ''. '.
`::: :+',;+' :+; `+.
:::: +' :' `+;
`:::, '+` ++ :+.`+; `++. ;+' '' ,++++.
,:::` `++'. .+: `+' `+; .+, ;+ +' +; ''
::::` ,+++. '+` :+. `+; `+, ;+ +' '+.
,. .:::: .++` `+: +' `+; `+, ;+ +' `;++;
`;;.:::` ::::: :+. '+,+. `+; `+, ;+ `+' .++
.;;;;;;::`.::::, +'` `++ `++' `+; `+: :+. `++' '. ;+
,;;;;;;;;;::::: .+++++` ;+, ++; ++, `'+++,'+' :++++,
,;;;;;;;;;:::` ;'
:;;;;;;;;;:, :.:+,
;;;;;;;;;: ;++,
Step 1 of 7. Checking system requirements.
------------------------------------------
Success! Your system can run Sylius properly.
Step 2 of 7. Setting up the database.
-------------------------------------
Creating Sylius database for environment prod.
The database sylius already exists and it has no tables.
1/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 100%
Loading sample data for environment prod from suite default.
Warning! This action will erase your database.
1/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 100%
Step 3 of 7. Shop configuration.
--------------------------------
Adding US Dollar currency.
Adding English Language.
Adding en_US locale.
Create your administrator account.
Step 4 of 7. Configuring JWT token.
-----------------------------------
Generating JWT token for Sylius API
Step 5 of 7. Generating payment encryption key.
-----------------------------------------------
Generating encryption key for Sylius payment encryption
[OK] Key has been generated and saved in "/var/www/sylius/config/encryption/dev.key"
Step 6 of 7. Installing assets.
-------------------------------
Installing Sylius assets for environment prod.
Created "/var/www/sylius/public/assets" directory.
Created "/var/www/sylius/public/bundles" directory.
1/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 100%
Step 7 of 7. Clearing cache.
----------------------------
// Clearing the cache for the prod environment with debug false
[OK] Cache for the "prod" environment (debug=false) was successfully cleared.
[OK] Sylius has been successfully installed.
You can now open your store at the following path under the website root: /
Sylius is now installed and running with all its services.
You can visit the dashboard to configure Sylius further, or access it directly at http://localhost:8080 or http://localhost:8080/admin.