smith89k / syno-sail
Docker configuration package for Laravel projects on Synology with GUI managers.
Requires
- php: ^8.0
- illuminate/console: ^9.0|^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^9.0|^10.0|^11.0|^12.0|^13.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
SynoSail
Run your Laravel app on a Synology NAS: build the image on GitHub, paste one stack into your Docker manager, press start.
SynoSail is a drop-in package designed for Laravel developers who want to deploy their applications on a Synology NAS using third-party Docker GUI managers like Dockhand, Dockge, Arcane, or Portainer.
For Node.js projects, use its sister package, SynoSail Node.
Why this package?
Deploying Laravel often involves building images and managing complex configurations. This package scaffolds a complete docker-compose.yml Stack designed specifically for Synology's strict folder permissions (tested on Synology NAS DS723+ running DSM 7.4) and GUI Docker managers.
It includes an init service that automatically copies pre-compiled assets, Nginx configs, and PHP configs into persistent, permission-safe data folders on your Synology NAS upon startup.
Step 1: Installation & Building (On Your Local Machine / CI)
First, install this package in your Laravel project via Composer:
composer require --dev smith89k/syno-sail
Next, publish the Docker configuration files to your project root.
For a first-time installation, run:
php artisan syno-sail:install
If you are updating the package and want to pull the latest versions of the stubs (Note: this will overwrite any custom changes you made to these files), run:
php artisan syno-sail:install --force
This command will copy the following into your project root:
Dockerfile(Used to build your image)docker-compose.yml(The stack you will deploy on Synology)docker/(Contains Nginx, PHP configs, and backup scripts).env.docker.example(Template for your production environment).dockerignore.github/(Contains a ready-to-use GitHub Actions workflow to build and push to GHCR)
Build & Push Your Image
The included GitHub Actions workflow builds the image and pushes it to GitHub Container Registry (GHCR) when you push to main. It uses a GHCR_PAT repository secret (a Personal Access Token with write:packages) if you add one, otherwise the repository's own token.
Alternatively, build locally:
docker build -t ghcr.io/<GITHUB_USER>/<APP_NAME>:latest -f Dockerfile . docker push ghcr.io/<GITHUB_USER>/<APP_NAME>:latest
Step 2: Preparing Dockhand (On Your Synology NAS)
Now that your image is on the registry, follow these strict steps on your Synology NAS to deploy it.
-
Create the Stack (Do not deploy yet!) Open Dockhand (or Dockge/Arcane/Portainer) and create a new Stack. Copy the contents of your
docker-compose.ymlinto the editor. Copy the contents of.env.docker.exampleinto the.enveditor and fill it in:CONTAINER_NAME,CONTAINER_REGISTRY_IMAGE,APP_PORT,APP_URL,APP_KEY,DB_DATABASE,DB_PASSWORD. Save the stack, but do NOT start it. -
Set Synology Folder Permissions (Crucial) Because Synology is strict about file creation permissions for Docker volumes, you must manually create the
datafolder first:- Open File Station in Synology DSM.
- Navigate to the folder where your stack was saved (e.g.,
/volume1/docker/dockhand/stacks/<ENVIRONMENT_OR_USER>/<PROJECT_NAME>/). - Create a new folder inside it named
data. - Right-click the
datafolder -> Properties -> Permission tab. - Give Everyone
Read & Writepermissions, and ensure you check "Apply to this folder, sub-folders and files".
-
Deploy the Stack Go back to your Docker manager and click Start/Deploy. Open
http://<NAS_IP>:<APP_PORT>.
What the Services Do
init: This is a temporary container that runs before everything else. Because you mapped./data, it takes the Nginx configs, PHP configs, and compiled Vite/public assets from inside your built image, and copies them to your physical Synologydatafolder.db: MariaDB instance for your application (optional, see below).app: The main PHP-FPM Laravel application.nginx: The web server, exposing the port specified byAPP_PORT(default8082) to route traffic to your app.
Turning the database on or off
Everything is set in .env; the docker-compose.yml never needs editing. The MariaDB database is optional and controlled by one line:
COMPOSE_PROFILES=db # database on (default) COMPOSE_PROFILES= # database off
With the database off, the db container is not created, the app starts without waiting for it, and the backup skips the database dump. This uses Docker Compose profiles and needs Docker Compose 2.20 or newer (check with docker compose version over SSH).
For a Laravel app without MariaDB, switch it to SQLite in the same .env; the file is created for you and kept (and backed up) with the rest of storage:
COMPOSE_PROFILES= DB_CONNECTION=sqlite DB_DATABASE=/var/www/storage/database.sqlite
Why security_opt: seccomp=unconfined?
You may notice the security_opt: ["seccomp=unconfined"] flag used in the services. Synology's DSM often runs on older Linux kernels with an outdated default seccomp profile in Docker. Newer Docker images (like Alpine or Debian bases) use new system calls (such as clone3) that are blocked by Synology's default profile, causing containers to instantly crash or fail to start. Setting seccomp=unconfined bypasses this outdated filter and allows the containers to run normally on Synology NAS without breaking.
Reaching the app from outside your home
Forward APP_PORT on your router, or use DSM Control Panel -> Login Portal -> Advanced -> Reverse Proxy. If your app uses WebSockets (live updates, chat, games), open the rule's Custom Header tab and click Create -> WebSocket, or the page will load but the live connection will fail.
Example Stack (copy & paste into Dockhand)
A complete stack for a Laravel app, served on port 8082 of your NAS. The docker-compose.yml and .env.docker.example below are exactly what php artisan syno-sail:install writes. Replace every <UPPERCASE> placeholder in the .env with your own value (see the table below); the docker-compose.yml needs no changes.
| Placeholder | What to put there |
|---|---|
<GITHUB_USER> |
Your GitHub user name, in lowercase. |
<APP_NAME> |
Your app's GitHub repository name, in lowercase. The workflow publishes the image as ghcr.io/<GITHUB_USER>/<APP_NAME>. |
<NAS_IP> |
Your NAS's address on your network (DSM Control Panel -> Network -> Network Interface). |
<DB_NAME> |
The database name, e.g. your app name with _ instead of -. |
<DB_PASSWORD> |
A strong password for the database's root user. |
<APP_KEY> |
The output of php artisan key:generate --show on your computer. |
<ENVIRONMENT_OR_USER>, <PROJECT_NAME> |
The folders your Docker manager saved the stack in. |
docker-compose.yml (paste into the stack editor)
services: init: image: ${CONTAINER_REGISTRY_IMAGE:-ghcr.io/<GITHUB_USER>/<APP_NAME>:latest} container_name: ${CONTAINER_NAME:-laravel}-init entrypoint: ["sh", "-c", "mkdir -p /mnt/stack/public && mkdir -p /mnt/stack/storage && mkdir -p /mnt/stack/mariadb && mkdir -p /mnt/stack/php && mkdir -p /mnt/stack/nginx && mkdir -p /mnt/stack/scripts && rm -rf /mnt/stack/public/* && cp -rf /var/www/public/. /mnt/stack/public/ && cp -rn /var/www/storage/. /mnt/stack/storage/ && cp -rf /var/www/docker/scripts/. /mnt/stack/scripts/ && (test -f /mnt/stack/php/php.ini || cp -f /tmp/php.ini /mnt/stack/php/php.ini) && (test -f /mnt/stack/nginx/nginx.conf || cp -f /tmp/nginx.conf /mnt/stack/nginx/nginx.conf)"] volumes: - ./data:/mnt/stack restart: "no" security_opt: - seccomp:unconfined db: # optional: runs only when COMPOSE_PROFILES in .env includes "db" profiles: ["db"] image: mariadb:11.4 container_name: ${CONTAINER_NAME:-laravel}-db restart: unless-stopped environment: - MARIADB_DATABASE=${DB_DATABASE:-laravel} - MARIADB_ROOT_PASSWORD=${DB_PASSWORD:-} - MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 - MARIADB_AUTO_UPGRADE=1 volumes: - ./data/mariadb:/var/lib/mysql depends_on: init: condition: service_completed_successfully healthcheck: test: ["CMD", "healthcheck.sh", "--innodb_initialized"] interval: 15s timeout: 10s retries: 3 start_period: 45s mem_limit: 768m memswap_limit: 1280m logging: driver: "json-file" options: max-size: "20m" max-file: "2" security_opt: - seccomp:unconfined app: image: ${CONTAINER_REGISTRY_IMAGE:-ghcr.io/<GITHUB_USER>/<APP_NAME>:latest} container_name: ${CONTAINER_NAME:-laravel}-app restart: unless-stopped environment: - APP_NAME=${APP_NAME:-laravel} - COMPOSE_PROFILES=${COMPOSE_PROFILES:-} - APP_ENV=${APP_ENV:-production} - APP_DEBUG=${APP_DEBUG:-false} - APP_KEY=${APP_KEY} - APP_TIMEZONE=${APP_TIMEZONE:-UTC} - APP_URL=${APP_URL:-http://localhost} - DB_CONNECTION=${DB_CONNECTION:-mysql} - DB_HOST=${DB_HOST:-db} - DB_PORT=${DB_PORT:-3306} - DB_DATABASE=${DB_DATABASE:-laravel} - DB_USERNAME=${DB_USERNAME:-root} - DB_PASSWORD=${DB_PASSWORD:-} - CACHE_STORE=${CACHE_STORE:-database} - SESSION_DRIVER=${SESSION_DRIVER:-database} - QUEUE_CONNECTION=${QUEUE_CONNECTION:-database} - QUEUE_WORKERS=${QUEUE_WORKERS:-1} volumes: - ./data/storage:/var/www/storage - ./data/php/php.ini:/usr/local/etc/php/conf.d/custom.ini:ro depends_on: init: condition: service_completed_successfully db: condition: service_healthy # the app still starts when the database is turned off required: false mem_limit: 384m memswap_limit: 768m logging: driver: "json-file" options: max-size: "20m" max-file: "2" security_opt: - seccomp:unconfined nginx: image: nginx:1.27-alpine container_name: ${CONTAINER_NAME:-laravel}-nginx restart: unless-stopped ports: - "${APP_PORT:-8082}:80" volumes: - ./data/public:/var/www/public - ./data/storage:/var/www/storage - ./data/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro depends_on: init: condition: service_completed_successfully app: condition: service_healthy mem_limit: 128m memswap_limit: 256m logging: driver: "json-file" options: max-size: "20m" max-file: "2" security_opt: - seccomp:unconfined
.env.docker.example (paste into the .env editor, then fill in the placeholders)
# Replace every <UPPERCASE> placeholder (see the README's placeholder table).
CONTAINER_NAME=<APP_NAME>
CONTAINER_REGISTRY_IMAGE=ghcr.io/<GITHUB_USER>/<APP_NAME>:latest
# which optional services run: "db" turns the MariaDB database on, empty turns it off
COMPOSE_PROFILES=db
APP_NAME="<APP_NAME>"
APP_ENV=production
APP_DEBUG=false
# the port on the NAS people open
APP_PORT=8082
# from `php artisan key:generate --show` on your computer
APP_KEY=<APP_KEY>
APP_TIMEZONE=Asia/Phnom_Penh
# the address people use to reach the app
APP_URL=http://<NAS_IP>:8082
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=<DB_NAME>
DB_USERNAME=root
DB_PASSWORD=<DB_PASSWORD>
CACHE_STORE=database
SESSION_DRIVER=database
QUEUE_CONNECTION=database
QUEUE_WORKERS=1
Step 3: Setting up Backups via DSM Task Scheduler
We've provided a backup.sh script (located in the published docker/scripts/ folder) to safely dump your database and compress your storage folder, keeping a 7-day retention.
Note on Backup Location: To prevent backups from being deleted if you remove or recreate your stack in Dockhand/Dockge, the script automatically saves backups outside the stack folder in /volume1/docker/backups/<PROJECT_NAME>. You can override this by defining BACKUP_DIR in your .env file.
To run this automatically every night:
- Open Control Panel in Synology DSM.
- Go to Task Scheduler -> Create -> Scheduled Task -> User-defined script.
- General: Name it "Laravel Backup", user
root. - Schedule: Set it to run daily at 2:00 AM.
- Task Settings: In the "Run command" box, execute the script. Make sure to pass the
DEPLOY_PATHof your stack:
cd /volume1/docker/dockhand/stacks/<ENVIRONMENT_OR_USER>/<PROJECT_NAME> DEPLOY_PATH=$(pwd) sh ./data/scripts/backup.sh
License
The MIT License (MIT).