standardnotes / server

Server ecosystem for Standard Notes; fully self-hostable.
https://standardnotes.com/help/self-hosting/docker
GNU General Public License v3.0
261 stars 62 forks source link

Cannot start Standardnotes with docker-compose #1059

Open TheBlusky opened 4 months ago

TheBlusky commented 4 months ago

I used last docker-compose file, but tweaked it for my usage:

version: "3.8"

services:
  server:
    image: standardnotes/server
    restart: always
    env_file: standardnotes.env
    volumes:
      - /docker/standardnotes/logs:/var/lib/server/logs
      - /docker/standardnotes/uploads:/opt/server/packages/files/dist/uploads
    networks:
      - web
      - default

  localstack:
    image: localstack/localstack:3.0
    restart: always
    environment:
      - SERVICES=sns,sqs
      - HOSTNAME_EXTERNAL=localstack
      - LS_LOG=warn
    volumes:
      - ./localstack_bootstrap.sh:/etc/localstack/init/ready.d/localstack_bootstrap.sh

  db:
    image: mysql:8.3
    restart: always
    environment:
      [...]
    volumes:
      - /docker/standardnotes/mysql:/var/lib/mysql
      - /docker/standardnotes/import:/docker-entrypoint-initdb.d

  cache:
    image: redis:6.0-alpine
    restart: always
    volumes:
      - /docker/standardnotes/redis/:/data

networks:
  web:
    external: true

When starting it, each containers starts properly, but service isn't working.

"syncing-server" is not launching, there are some errors with migrations:

==> syncing-server.log <==
query: SELECT VERSION() AS `version`
info: All classes found using provided glob pattern "/opt/server/packages/syncing-server/dist/src/Bootstrap/../../migrations/mysql/*.js" : "/opt/server/packages/syncing-server/dist/migrations/mysql/1606470249552-init_database.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1617615657558-add_extension_settings.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1629964808297-drop_unused_indexes.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1630318893601-refactor_calculating_integrity_hash.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1630417724617-restrict_content_type.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1631529502150-add_revision_for_duplicated_items.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1631530260504-drop_item_revisions_joining_table.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1632219307742-cleanup_orphan_items_and_revisions.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1632221263106-add_revisions_items_relation.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1637738491169-add_item_content_size.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1639134926025-remove_extension_settings.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1642073387521-remove_sf_extension_items.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1647501696205-remove_user_agent.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1654518291191-add_updated_with_session.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1689671563304-add-notifications.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1689671563305-add-shared-vault-and-key-system-associations.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1689677728282-add-shared-vaults-with-users-and-invites.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1689745128577-add-messages.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1689746180559-rename-key-message-identifier.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1690900526061-delete_privileges.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1690975361562-update_unknown_content.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1692176803410-remove_revisions_foreign_key.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1692264556858-remove_associations.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1692619430384-remove-shared-vault-limit.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1693219736168-add-shared-vault-information.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1695284084365-add-designated-survivor.js,/opt/server/packages/syncing-server/dist/migrations/mysql/1695643525793-remove_notifications.js"
query: SELECT * FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = 'mysql' AND `TABLE_NAME` = 'migrations'
query: SELECT * FROM `mysql`.`migrations` `migrations` ORDER BY `id` DESC
24 migrations are already loaded in the database.
27 migrations were found in the source code.
RemoveSharedVaultLimit1692619430384 is the last executed migration. It was executed on Mon Aug 21 2023 12:03:50 GMT+0000 (Coordinated Universal Time).
3 migrations are new migrations must be executed.
query: START TRANSACTION
query: ALTER TABLE `items` ADD `last_edited_by` varchar(36) NULL, ALGORITHM = INSTANT
query failed: ALTER TABLE `items` ADD `last_edited_by` varchar(36) NULL, ALGORITHM = INSTANT
error: Error: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=COPY/INPLACE.
query: ROLLBACK

==> error: Error: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=COPY/INPLACE.

After googling this error, it looked like an issue with MySQL version.

I tried reseting the DB and using 8, 8.0, 8.3, all gave the same error.

stevesbrain commented 2 months ago

Mine's on mysql:8, but I'm using standardnotes/server:5c02435ee478b893747d3f9e41062aae12d7ff10 to go with it. Don't forget to remove local data directories created by the bootstrapping script between version tests as well; might be impacting things.

RamonAbudAlcala commented 1 month ago

I have essentially the same docker compose setup, with mysql 8, double check your environment variables.

DB_HOST=db
DB_PORT=3306
DB_USERNAME=std_notes_user
DB_PASSWORD=...
DB_DATABASE=standard_notes_db
DB_TYPE=mysql
MYSQL_DATABASE=standard_notes_db
MYSQL_USER=std_notes_user
MYSQL_ROOT_PASSWORD=...
MYSQL_PASSWORD=...
REDIS_PORT=6379
REDIS_HOST=cache
CACHE_TYPE=redis
AUTH_JWT_SECRET=...
AUTH_SERVER_ENCRYPTION_SERVER_KEY=...
VALET_TOKEN_SECRET=...
PUBLIC_FILES_SERVER_URL="https://custom.app.url.here:3104"
COOKIE_DOMAIN=custom.app.url.here

I gave both the server and the db containers all these variables because I could not be bohered to have db username and password in two different places.