standardnotes / self-hosted

[Legacy] Self-host your own Standard Notes server for end-to-end encrypted notes and files
https://github.com/standardnotes/server
GNU Affero General Public License v3.0
343 stars 39 forks source link

Fresh install of self-hosted: db doesn't start up #111

Closed macdonaldj closed 1 year ago

macdonaldj commented 1 year ago

Service Versions (please complete the following information): Paste the output of ./server.sh version. For example:

             Container                          Repository                 Tag         Image Id       Size
------------------------------------------------------------------------------------------------------------
./server.sh version
CONTAINER                              REPOSITORY                        TAG                 IMAGE ID            SIZE
api-gateway-self-hosted                standardnotes/api-gateway         latest              691d160ab707        207MB
auth-self-hosted                       standardnotes/auth                latest              69adf8a89074        222MB
auth-worker-self-hosted                standardnotes/auth                latest              69adf8a89074        222MB
cache-self-hosted                      redis                             6.0-alpine          374a6ec6dd63        26.3MB
db-self-hosted                         mysql                             5.6                 dd3b2a5dcb48        303MB
files-self-hosted                      standardnotes/files               latest              8613abf8ad9a        208MB
files-worker-self-hosted               standardnotes/files               latest              8613abf8ad9a        208MB
revisions-db-self-hosted               mysql                             8                   7484689f290f        538MB
revisions-self-hosted                  standardnotes/revisions           latest              ed0b47a8e2f4        217MB
revisions-worker-self-hosted           standardnotes/revisions           latest              ed0b47a8e2f4        217MB
self-hosted-localstack-1               localstack/localstack             latest              5cf80fe4d342        1.85GB
syncing-server-js-self-hosted          standardnotes/syncing-server-js   latest              997036d1a7f3        219MB
syncing-server-js-worker-self-hosted   standardnotes/syncing-server-js   latest              997036d1a7f3        219MB

Following guide from https://docs.standardnotes.com/self-hosting/docker/ Step 8 shows the db keeps restarting

Logs

2023-01-11T20:33:55.085128534Z ls: cannot open directory '/docker-entrypoint-initdb.d/': Permission denied
2023-01-11T20:34:46.892399526Z 2023-01-11 20:34:46+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.51-1debian9 started.
2023-01-11T20:34:46.964668005Z 2023-01-11 20:34:46+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2023-01-11T20:34:46.972145700Z 2023-01-11 20:34:46+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.51-1debian9 started.
2023-01-11T20:34:47.044699161Z ls: cannot open directory '/docker-entrypoint-initdb.d/': Permission denied
macdonaldj commented 1 year ago

might be related to users, this was done on an AWS 20.04, afer server start i see this

self-hosted/data# ll
drwx------ 7 root             docker 4096 Jan 12 15:29 ./
drwx------ 6 root             docker 4096 Jan 12 15:29 ../
-rw------- 1 root             docker    0 Jan 12 15:29 .gitkeep
drwx------ 2 root             docker 4096 Jan 12 15:29 import/
drwxr-xr-x 2 systemd-coredump docker 4096 Jan 12 16:12 mysql/
drwxr-xr-x 2 systemd-coredump docker 4096 Jan 12 15:29 redis/
drwxr-xr-x 8 systemd-coredump docker 4096 Jan 12 16:10 revisions-db/
drwx------ 2 root             docker 4096 Jan 12 15:29 uploads/
macdonaldj commented 1 year ago

still having issues, any thoughts @eric-pierce ?

macdonaldj commented 1 year ago

it is def a permissions issue, this fixed it, which obviously is not a solution we can pursue

cd self-hosted
chmod -R 777 .
./server.sh start
eric-pierce commented 1 year ago

@macdonaldj I'm not leveraging the script based install, but am instead using a manually maintained docker-compose and mariadb instead of MySQL, so I'm not seeing these same issues.

It looks like the problem may be folder and file permission focused, where some of your folders are only readable by root, and others are readable by non-root users. I'm betting that if you take a look at your mysql folder and file permissions you may find the cause.

Depending on how open you want your permissions to be and what your threat model is, your solution above could be fine.

macdonaldj commented 1 year ago

thanks for the response. Im def interested to hear more about the manual maintained method with maria ;)

but for now this seemed to get me moving find . -type d -exec chmod 775 {} \;

eric-pierce commented 1 year ago

@macdonaldj you can take a look at my docker-compose file which includes all services (both StandardNotes and other). I'm not affiliated with StandardNotes at all and my approach isn't official, but it fits with my container management workflow much better than the script approach.