benotes
benotes copied to clipboard
Running Benotes on Synology
Hello. I try to run Benotes with Docker on my Synology.
I have follow our instructions to run it inside Docker:
docker run -p 8558:80 -it --rm \
-v /volume1/docker/benotes/storage:/var/www/storage \
-v /volume1/docker/benotes/logs/:/var/lib/nginx/logs/ \
-v /volume1/docker/benotes/env:/var/www/.env \
--env-file /volume1/docker/benotes/env/.env \
--name benotes fr0tt/benotes
env:
APP_NAME=Benotes
APP_ENV=production
APP_DEBUG=false
APP_URL=secret
APP_KEY=secret
JWT_SECRET=secret
USE_FILESYSTEM=true
RUN_MIGRATIONS=false
DB_CONNECTION=sqlite
DB_HOST=
DB_PORT=
DB_DATABASE=storage/database.sqlite
DB_USERNAME=
DB_PASSWORD=
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
MAIL_DRIVER=smtp
MAIL_HOST=
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME="Benotes"
in my error.logI see this:
2022/12/01 09:23:35 [error] 67#67: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/storage/logs/lumen-2022-12-01.log" could not be opened in append mode: failed to open stream: Permission denied
The exception occurred while attempting to log: The stream or file "/var/www/storage/logs/lumen-2022-12-01.log" could not be opened in append mode: failed to open stream: Permission denied
The exception occurred while attempting to log: The stream or file "/var/www/storage/logs/lumen-2022-12-01.log" could not be opened in append mode: failed to open stream: Permission denied
The exception occurred while attempting to log: The stream or file "/var/www/storage/logs/lumen-2022-12-01.log" could not be opened in append mode: failed to open stream: Permission denied
The exception occurred while attempting to log: The stream or file "/var/www/storage/logs/lumen-2022-12-01.log" could not be opened in append mode: failed to open stream: Permission denied
The exception occurred while attempting to log: Please provide a valid cache path.
Some way to turn off this logs or solve the error?
let my know if you need some further information.
Thanks a lot
Hey,
seems like /volume1/docker/benotes/storage
is not writeable for the docker container. It tries to create files inside that directory but fails.
Thanks for the quick response. But in this folder the database.sqlite file is created successfully. I have add the file: /volume1/docker/benotes/storage/logs/lumen-2022-12-01.log manually.
thats the output of my terminal: -> Executing /opt/docker/provision/entrypoint.d/05-permissions.sh -> Executing /opt/docker/provision/entrypoint.d/20-nginx.sh -> Executing /opt/docker/provision/entrypoint.d/20-php-fpm.sh -> Executing /opt/docker/provision/entrypoint.d/20-php.sh -> Executing /entrypoint.d/app_entrypoint.sh /entrypoint.d/app_entrypoint.sh: line 7: [: missing `]' -> Executing /opt/docker/bin/service.d/supervisor.d//10-init.sh 2022-12-01 10:27:58,671 INFO Included extra file "/opt/docker/etc/supervisor.d/cron.conf" during parsing 2022-12-01 10:27:58,671 INFO Included extra file "/opt/docker/etc/supervisor.d/dnsmasq.conf" during parsing 2022-12-01 10:27:58,671 INFO Included extra file "/opt/docker/etc/supervisor.d/nginx.conf" during parsing 2022-12-01 10:27:58,671 INFO Included extra file "/opt/docker/etc/supervisor.d/php-fpm.conf" during parsing 2022-12-01 10:27:58,672 INFO Included extra file "/opt/docker/etc/supervisor.d/postfix.conf" during parsing 2022-12-01 10:27:58,672 INFO Included extra file "/opt/docker/etc/supervisor.d/ssh.conf" during parsing 2022-12-01 10:27:58,672 INFO Included extra file "/opt/docker/etc/supervisor.d/syslog.conf" during parsing 2022-12-01 10:27:58,672 INFO Set uid to user 0 succeeded 2022-12-01 10:27:58,730 INFO RPC interface 'supervisor' initialized 2022-12-01 10:27:58,731 INFO supervisord started with pid 1 2022-12-01 10:27:59,735 INFO spawned: 'syslogd' with pid 45 2022-12-01 10:27:59,738 INFO spawned: 'nginxd' with pid 46 2022-12-01 10:27:59,742 INFO spawned: 'php-fpmd' with pid 47 2022-12-01 10:27:59,745 INFO spawned: 'crond' with pid 48 -> Executing /opt/docker/bin/service.d/syslog-ng.d//10-init.sh 2022-12-01 10:27:59,754 INFO success: nginxd entered RUNNING state, process has stayed up for > than 0 seconds (startsecs) 2022-12-01 10:27:59,754 INFO success: php-fpmd entered RUNNING state, process has stayed up for > than 0 seconds (startsecs) 2022-12-01 10:27:59,754 INFO success: crond entered RUNNING state, process has stayed up for > than 0 seconds (startsecs) -> Executing /opt/docker/bin/service.d/nginx.d//10-init.sh -> Executing /opt/docker/bin/service.d/php-fpm.d//10-init.sh Setting php-fpm user to application -> Executing /opt/docker/bin/service.d/cron.d//10-init.sh crond[48]: crond (busybox 1.35.0) started, log level 8 [2022-12-01T10:28:00.213933] WARNING: With use-dns(no), dns-cache() will be forced to 'no' too!; [SYSLOG] syslog-ng[45]: syslog-ng starting up; version='3.36.1' 2022-12-01 10:28:01,214 INFO success: syslogd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) [01-Dec-2022 10:28:02] NOTICE: fpm is running, pid 47 [01-Dec-2022 10:28:02] NOTICE: ready to handle connections crond[48]: USER root pid 71 cmd run-parts /etc/periodic/15min
the only ones that looks wrong are: /entrypoint.d/app_entrypoint.sh: line 7: [: missing `]' and 2022-12-01 10:27:58,672 INFO Set uid to user 0 succeeded
I think the second one is the bad one:
uid 0 could have no permissions to write in the file /volume1/docker/benotes/storage/logs/lumen-2022-12-01.log
is it possible to set the uid?
Well adding the file manually will only fix it for today :D
The container should be able to do that without your help. It should run under user application
(UID 1000).
I guess that answer is probably not good enough, but I have to tinker with it myself first (this evening or probably at the weekend).
In addition to that you can get the applications users inside the container with
id -u
and check if it is 1000.
If not run the following command on your container to give the proper usermod and groupmod to the application
user.
docker exec -uroot YOUR_CONTAINER_NAME /bin/bash -c "usermod -u 1001 application"
docker exec -uroot YOUR_CONTAINER_NAME /bin/bash -c "groupmod -g 1001 application"
@FTeinz were you able to get it to work? I am also trying to deploy docker container and facing same error.
@mohit-kothari Sorry no, I didn't find time to take care of it. If so I will post my solution.
@mohit-kothari And none of the above ideas/information I provided helped ?
Ana found the fix to that error, is a problem with laravel not finding some folders. It's explained here Create a folder called "framework" inside "storage", and subfolders "sessions" "views" and "cache" and the error would stop
I wasn't sure if it was the fix so I deleted my response... I guess you still received the email and managed to fix it. Glad it helped @FTeinz
Oh it seems not to be a fix. The Webinterface is now accessible but the log in seems not to show any response for the cardinals I have typed after:
php artisan migrate
and
php artisan install --only-user
Check that files and folders all have the right permission, is the first thing I think about because it has been a big issue for me experimenting with benotes
Perhaps the newest version finally resolves it ?
I ran pretty much stock compose with the beta tag in Portainer on my Synology and it worked fine. I only changed so I use bind mounts and the port in the .env file.
My compose looks like this if that can help someone
version: "3.6"
services:
app:
container_name: benotes_app
image: fr0tt/benotes:2.7.0-beta
restart: unless-stopped
environment:
DB_CONNECTION: ${DB_CONNECTION}
ports:
- ${APP_PORT}:80
volumes:
- /volume1/docker/benotes/.env:/var/www/.env
- /volume1/docker/benotes/storage/thumbnails:/var/www/storage/app/public/thumbnails
- /volume1/docker/benotes/storage/backup:/var/www/storage/backup
- /volume1/docker/benotes/storage/logs:/var/www/storage/logs
networks:
- benotes
db:
container_name: benotes_db
image: postgres:15.2-alpine
restart: unless-stopped
environment:
POSTGRES_DATABASE: ${DB_DATABASE}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_PASSWORD: ${DB_PASSWORD}
ports:
- ${DB_PORT}
volumes:
- /volume1/docker/benotes/postgres:/var/lib/postgresql/data
networks:
- benotes
networks:
benotes:
driver: bridge
Since this issue is still open, I wanted to share how I managed to get Benotes to run on my Synology NAS using Docker (DSM 7.1):
Please note: This follows the installation docs for docker-compose.
-
Create a directory for persistent data on the DiskStation, e.g.
/volume1/docker/benotes
-
Create the following subdirectories:
-
/volume1/docker/benotes/storage/app/public/thumbnails
-
/volume1/docker/benotes/storage/backup
-
/volume1/docker/benotes/storage/logs
-
/volume1/docker/benotes/postgres
-
-
Create a directory
/volume1/docker/benotes/docker-compose
-
Download docker-compose.yml from
https://github.com/fr0tt/benotes_docker-compose
and put in inside/volume1/docker/benotes/docker-compose
. -
Download .env.example from https://github.com/fr0tt/benotes_docker-compose and put in inside
/volume1/docker/benotes/docker-compose
. -
Rename
.env.example
to.env
and edit it if necessary (e.g. if you need to change the local port from 8000 to something different in order to avoid conflicts; Portainer uses this port by default). To edit this (or any) text file directly in DSM, you can use Text Editor, which can be installed via DSM's Package Center. -
Edit
docker-compose.yml
so that the volumes are mounted to the one created in step 2 (once again, you can use Text Editor to do this within DSM.)- a) In line 12, change
.env:/var/www/.env
to/volume1/docker/benotes/docker-compose/.env:/var/www/.env
- b) In line 13, remove the
#
(i.e. uncomment the line) and change./data/storage/app/public/thumbnails:/var/www/storage/app/public/thumbnails
into/volume1/docker/benotes/storage/app/public/thumbnails:/var/www/storage/app/public/thumbnails
. - c) In line 14, remove the
#
(i.e. uncomment the line) and change/data/storage/backup:/var/www/storage/backup
into/volume1/docker/benotes/storage/backup:/var/www/storage/backup
. - d) In line 15, remove the
#
(i.e. uncomment the line) and change/data/storage/logs:/var/www/storage/logs
into/volume1/docker/benotes/storage/logs:/var/www/storage/logs
. - e) In line 17, put a
#
as first character before- benotes_storage:/var/www/storage
in order to deactivate/comment the line. - f) In line 34, change
benotes_postgres:/var/lib/postgresql/data
into/volume1/docker/benotes/postgres:/var/lib/postgresql/data
.
- a) In line 12, change
-
In FileStation, right-click on the folder created in step 1 and choose Properties > Permissions > Make inherited permissions explicit > "Everyone" > Edit. Tick "Write" to grant write access to
Everyone
. (Please note: There are certainly safer ways to accomplish this! This goes beyond the scope of this how-to, though.) -
Open a terminal on your computer and use the following commands:
- a) SSH into your DiskStation:
ssh your-syno-user-name@your-syno-ip-address
(e. g.ssh [email protected]
). - b) Elevate to root user:
sudo -i
- c) Navigate to the path created in step 3:
cd /volume1/docker/benotes/docker-compose
- d) Spin up the containers:
docker-compose up -d
. (If successful, after a few seconds, in Synology's Docker GUI (inside DSM) you will see two containers appear:benotes_app
andbenotes_db
.) - e) Enter the Benotes app container:
docker-compose exec --user application app sh
- f) Initialize Benotes (create admin account, etc.):
php artisan install
; enteryes
to the questions asked. If this command fails with an error, there's probably something wrong with the read/write permissions (see step 8).
- a) SSH into your DiskStation:
-
You should now be able to log in to Benotes using the admin account's e-mail address and password you declared in step 9f.
Hi. I found some time to follow your guide, which is really great. Because I use the same folder structure I can use your guide really easy. But I am not finished.
- One thing to add to your guide is to create this folder at the beginning: /volume1/docker/benotes/postgres. I got an error because it did not exist.
- I am stuck at: php artisan install at the third step (see below). I think this has something to do with the wrong/missing editing of the .yml and .env file?
In the .env file I only changed the port in the first line to 8001 (APP_PORT=8001) The .yml file I changed according to your guide.
-
Application In Production! *
Do you really wish to run this command? (yes/no) [no]:
yes
Illuminate\Database\QueryException
SQLSTATE[08006] [7] connection to server at "db" (172.18.0.2), port 5432 failed: timeout expired (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712 708▕ // If an exception occurs when attempting to run a query, we'll format the error 709▕ // message to include the bindings with SQL, which will make this exception a 710▕ // lot more helpful to the developer instead of just the database's errors. 711▕ catch (Exception $e) { ➜ 712▕ throw new QueryException( 713▕ $query, $this->prepareBindings($bindings), $e 714▕ ); 715▕ } 716▕ }
+30 vendor frames
31 app/Console/Commands/InstallCommand.php:57 Illuminate\Console\Command::call("migrate")
+13 vendor frames
45 artisan:37 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
Try the fix mentioned before at https://github.com/fr0tt/benotes/issues/43#issuecomment-1419800803
I tried the fix, but it does not work. Nothing changed. I created a folder "framework" inside "storage" and inside "framework" the 3 folders "sessions", "views" and "cache"
That fix is only suiteable if you use the entire storage directory as bind mount which isn't the case if you follow @philipp-koch instructions or the official ones.
In any case your issue seems to be that Benotes can't connect to the PostgreSQL database. It could be an issue with your docker-compose.yml or .env file or the database itself. Hard to tell with only this vague error message at hand.
Thats a pity. I was so close in running benotes
@Sylvio82 Have you tried altering the read/write permissions of /volume1/docker/benotes/
as described in step 8?
You're right, the postgres folder creation was missing, I've edited my post accordingly. I've also changed it so that it doesn't refer to the beta version any longer, since it now works using the latest
tag just fine. You might want to try it with the latest docker_compose.yml (linked) should you have used an older one.
I downloaded the latest docker-compose.yml, I set write permissions for everyone and I am using the latest stable version. I got the same error message as if nothing changed.
Hi all,
Here is what I've done to quickly test Benotes on Synology through Portainer using an SQLite DB (for really quick testing purposes):
On the Syno box through ssh:
mkdir -p /volume1/docker/benotes/storage/app/public/thumbnails
mkdir -p /volume1/docker/benotes/storage/backup
mkdir -p /volume1/docker/benotes/storage/logs
mkdir -p /volume1/docker/benotes/postgres
mkdir -p /volume1/docker/benotes/docker-compose
- I also gave here "everyone" R/W access inherited to /volume1/docker/benotes/ (from the Syno DSM File Station).
Portainer docker-compose instructions:
version: "3.6"
services:
app:
container_name: benotes_app
image: fr0tt/benotes:2.7.0-beta
restart: unless-stopped
environment:
DB_CONNECTION: sqlite
ports:
- 22400:80
volumes:
- /volume1/docker/benotes/.env:/var/www/.env
- /volume1/docker/benotes/storage/thumbnails:/var/www/storage/app/public/thumbnails
- /volume1/docker/benotes/storage/backup:/var/www/storage/backup
- /volume1/docker/benotes/storage/logs:/var/www/storage/logs
networks:
- benotes
networks:
benotes:
driver: bridge
Import the ".env" file within Portainer:
APP_NAME=Benotes
APP_ENV=production
APP_DEBUG=false
APP_URL=http://synobox.local:7443
APP_KEY=
JWT_SECRET=
GENERATE_MISSING_THUMBNAILS=true
USE_FILESYSTEM=true
DB_CONNECTION=sqlite
DB_HOST=
DB_PORT=
DB_DATABASE=/var/www/storage/database.sqlite
DB_USERNAME=
DB_PASSWORD=
MAIL_DRIVER=smtp
MAIL_HOST=
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME="Benotes"
On the Benotes container itself (ssh console on the container):
php artisan install
chmod -R 774 PWD$/storage/
Obviously, a reverse proxy at the Synology DSM from HTTPS:TCP:7443_to_HTTP:TCP:22400 has been put in place as well. Therefore, I reach my Benotes from: https://syno.local:7443 and logon with the set administrative credentials.
Working all fine here, although TBH there are a few things I do not understand I.E: why you can click on a note and that doesn't open it? I might have missed something though...
Hope this helps. Cheers, o.
Thanks for your tutorial. (Btw there is of course no need for a postgres volume if you use Sqlite instead.) Clicking on a note allows you to quick-edit it without opening it in full size and losing the context of your surrounding posts/notes.
I had the same issue. The main problem is that Synology users are unable to create a user with puid 1000. Synology's first user is created in the 1024 range. Containers that allow the PUID and GUID to be changed in the docker compose can be run on Synology. I don't see that this image is accepting the ability to set the PUID and GUID in the compose file. Can that functionality be added?
Yes, I'm going to add that.