Migrate Dockerized Community 7 to Pro 7

How to properly upgrade a docker deployed community 7 server to docker deployed pro 7?

I changed my docker-compose to comply with

https://download.seafile.com/published/support/docker/pro-edition/Deploy%20Seafile-pro%20with%20Docker.md

This new documentation for version 7 says nothing about migration from community to pro. Nevertheless the pro.py still exists and has the option setup --migrate.
But in docker containers this does not work:

Traceback (most recent call last):
  File "./pro/pro.py", line 836, in <module>
    main()
  File "./pro/pro.py", line 833, in main
    args.func(args)
  File "./pro/pro.py", line 704, in do_setup
    env_mgr.read_seafile_conf_dir()
  File "./pro/pro.py", line 341, in read_seafile_conf_dir
    with open(seafile_ini, 'r') as fp:
IOError: [Errno 2] No such file or directory: '/opt/seafile/ccnet/seafile.ini'

The ccnet directory is in the /shared directory not in the /opt/seafile but this is not known to the script.

If I copy the /opt/seafile/seafile-pro-server-7.0.4directory to /shared/seafile and execute the pro.py setup --migrate script, it succeeds without error.

But now I have the problem that all libraries are somehow unconnected. And in seafile.log I have:

Error prepare statement [...]
Table 'seafile_db.RepoStorageId' doesn't exist.
Table 'seafile_db.FileLocks' doesn't exist.

So the pro migration script did not create all necessary tables.

On this forum I found a post from a seafile official that recommends creating the sql tables by hand in another case. So I have done that in this case according to:

Now “everything” works. So if there is an official way I did not find it. But my way worked somehow. I will report back if I encounter errors.

I found out, that my way of docker-compose run prevented the pro.py script from working. So my copy-the-directory workaround is not necessary if you invoke the pro.py script by docker-compose exec.

Nevertheless elasticsearch did not work:

Replacing the [INDEX FILES] section in seafevents.conf with the following is one step forward:

[INDEX FILES]
external_es_server = true
es_host = elasticsearch
es_port = 9200
enabled = true
interval = 10m

highlight = fvh

## If true, indexes the contents of office/pdf files while updating search index
## Note: If you change this option from "false" to "true", then you need to clear the search index and update the index again. See the FAQ for details.
index_office_pdf = true

And then I found out that in the current image seafileltd/elasticsearch-with-ik:5.6.16 the file /docker-entrypoint.sh seems to have a bug:

The exec gosu line has been commented out for some reason and will result in running elasticsearch with root permissions. But elasticsearch refuses to start as root and throws exceptions.

Inserting user: elasticsearch in the docker-compose.yml in the elasticsearch section solved this and search is now running.

Glad you could fix your problem. Please mark as solved then.

Same problem here: elasticsearch throws errors
In seafile-data/logs/seafile/elasticsearch.log

[2019-08-13T19:16:10,704][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

inserting user: elasticsearch in docker-compose.yml does not help.

my elasticsearch part looks like this:

elasticsearch:
  image: seafileltd/elasticsearch-with-ik:5.6.16
  container_name: seafile-elasticsearch
  environment:
    - discovery.type=single-node
    - bootstrap.memory_lock=true
    - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
  user: elasticsearch
  ulimits:
    memlock:
      soft: -1
      hard: -1
  mem_limit: 2g
  volumes:
    - /srv/seafile/seafile-elasticsearch/data:/usr/share/elasticsearch/data

Same error message? The docker daemon will not execute the container with root permissions if you have the user directive. Did you recreate the container after changing the compose file? docker-compose up recreates it on the fly.

Docker security would be really messed up, if you have this compose directive and still root permissions inside.

You could test this by docker-compose run --rm elasticsearch whoami. Should simply return “elasticsearch”.

I did a docker-compose down followed by a docker-compose up

docker-compose run --rm elasticsearch whoami gives me elasticsearch

however, I still get the same error:
[2019-08-14T15:29:20,277][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main] org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root