Synology NAS Docker Compose
This is a customized version of the advanced Docker Compose configuration for running AdamRMS with a MySQL database inside of a Synology NAS. This configuration is suitable for production use, and includes hourly mysql backups.
Uploaded files and database backups are kept in folders next to the docker-compose.yml file (files and backups), using local file storage, so no S3 service is needed and both are included when you back up the folder with Hyper Backup. If you would rather keep files in an S3-compatible service, see File & Image Storage.
Upload the docker-compose.yml file in the same directory as the .env on your Synology, and create the files and backups folders next to it.
services:
adamrms_db:
image: index.docker.io/mysql/mysql-server:8.0
command: --default-authentication-plugin=mysql_native_password --innodb-thread-concurrency=0 --sort_buffer_size=512K
container_name: adamrms_db
#ports: # Disable this if you would like to keep the database on the local machine only (recommended)
# - 3306:3306
volumes:
- adamrms_db_data:/var/lib/mysql
- /etc/localtime:/etc/localtime:ro
restart: always
environment:
- MYSQL_DATABASE=adamrms
- MYSQL_ROOT_HOST=%
- MYSQL_USER=userDocker
- MYSQL_PASSWORD=passDocker
env_file:
- .env
healthcheck:
test:
[
"CMD",
"mysqladmin",
"ping",
"-h",
"localhost",
"-u",
"root",
"-p$$MYSQL_ROOT_PASSWORD",
]
timeout: 20s
retries: 10
adamrms:
image: ghcr.io/adam-rms/adam-rms:latest
container_name: adamrms
restart: always
depends_on:
adamrms_db:
condition: service_healthy
environment:
- DB_HOSTNAME=adamrms_db
- DB_DATABASE=adamrms
- DB_USERNAME=userDocker
- DB_PASSWORD=passDocker
- DB_PORT=3306
- DEV_MODE=false
- CONFIG_FILES_ENABLED=Enabled
- CONFIG_FILES_STORAGE_DRIVER=Local
volumes:
- ./files:/var/www/html/storage
user: root
ports:
- "8089:80"
adamrms_mysql-backup:
image: index.docker.io/databack/mysql-backup:1.0.0-rc5
restart: unless-stopped
container_name: adamrms_mysql-backup
command: dump
environment:
- DB_SERVER=adamrms_db
- DB_PORT=3306
- DB_USER=userDocker
- DB_PASS=passDocker
- DB_NAMES=adamrms
- NO_DATABASE_NAME=true
- DB_DUMP_FREQUENCY=60 #Hourly
- DB_DUMP_BEGIN=+2
- COMPRESSION=gzip
- DB_DUMP_SAFECHARS=true
- NICE=true
- DB_DUMP_TARGET=/db
env_file:
- .env
depends_on:
adamrms_db:
condition: service_healthy
user: root
volumes:
- /etc/localtime:/etc/localtime:ro
- ./backups:/db
adamrms_watchtower:
image: index.docker.io/containrrr/watchtower:1.7.1
container_name: adamrms_watchtower
restart: always
environment:
- WATCHTOWER_CLEANUP=true
- WATCHTOWER_POLL_INTERVAL=60
volumes:
- /var/run/docker.sock:/var/run/docker.sock
volumes:
adamrms_db_data: {}
Environment Variables
Place the following environment variables in a .env file in the same directory as the docker-compose.yml file.
# For the remote mysql access, set a root password
MYSQL_ROOT_PASSWORD=
Create the Project
Go to your Synology Nas -> Container Manager -> Projects -> Create.
Give it a Name and select the Folder where you stored your docker-compose.yml, then select use existing.
Once the project has started, AdamRMS is available on port 8089 of your NAS, and files can be uploaded straight away.
Moving from MinIO
Earlier versions of this guide stored files in MinIO. To move them into the files folder:
-
Create the
filesfolder, and add it to theadamrmsservice as above (./files:/var/www/html/storage), but keep MinIO and theCONFIG_AWS_S3_*settings for now. Make sureCONFIG_AWS_S3_SERVER_ENDPOINTuses MinIO's S3 API port,http://adamrms_minio:9000- earlier versions of this guide gave port 9001, which is MinIO's web console. -
Copy the files across:
docker exec -it adamrms php bin/file-storage.php migrate --to=Local -
Switch to the configuration above, which stores new uploads locally, and remove MinIO once you are happy everything is there.
See moving files between drivers for more.