proycon / flat

FoLiA Linguistic Annotation Tool -- Flat is a web-based linguistic annotation environment based around the FoLiA format (http://proycon.github.io/folia), a rich XML-based format for linguistic annotation. Flat allows users to view annotated FoLiA documents and enrich these documents with new annotations, a wide variety of linguistic annotation types is supported through the FoLiA paradigm.
GNU General Public License v3.0
111 stars 15 forks source link

Installing with Docker -- only document server is visible #183

Closed pirolen closed 2 years ago

pirolen commented 2 years ago

Hi Maarten, we are trying to install FLAT on an Ubuntu 20 Server VM, with Docker. Is the image supposed to function on a server as well out of the box, or are there specific parameters that we need to modify? (e.g. ENV FLAT_DOMAIN="localhost"?) https://flat.readthedocs.io/en/latest/installation_guide.html#deployment-in-production

Running the container only worked when "--network=host" was passed to docker-run.

The command we used was: docker run --name flat -d --restart unless-stopped --network="host" -p 8080:80 -v /home/pirol/flat/data:/data -v /home/pirol/flat/settings/:/etc/flat --env FLAT_EMAIL=XXmyemailXX proycon/flat

The container is running, but one sees in the Browser only the GUI of the document server.

I tried to upload a folia document there: I am able to select it, but nothing happens if I click the upload button.

Screen Shot 2022-11-21 at 12 16 06
proycon commented 2 years ago

Hi Piroska,

On 22-11-21 03:57, pirolen wrote:

Is the image supposed to function on a server as well out of the box, or are there specific parameters that we need to modify? (e.g. ENV FLAT_DOMAIN="localhost"?)

You can use the provided image as is, but you do need to set the environment variables like FLAT_DOMAIN indeed, there's a list of them here: https://flat.readthedocs.io/en/latest/installation_guide.html#deployment-in-production . You can pass them at runtime using --env.

Running the container only worked when "--network=host" was passed to docker-run.

That's actually the source of your problem. I recommend the normal bridge mode. Why didn't that work?

The command we used was: docker run --name flat -d --restart unless-stopped --network="host" -p 8080:80 -v /home/pirol/flat/data:/data -v /home/pirol/flat/settings/:/etc/flat --env FLAT_EMAIL=XXmyemailXX proycon/flat

The container is running, but one sees in the Browser only the GUI of the document server.

Due to the host network mode, the -p parameter has no effect. This means the document server will be on port 8080 (as you noticed), and FLAT itself will be on port 80 (assuming docker has sufficient permission and nothing is running there yet)

Also note that in host network mode, you may be exposing the document server to the internet directly (unless there is a firewall blocking port 8080), which is a security risk!

pirolen commented 2 years ago

well out of the box, or are there specific parameters that we need to modify? (e.g. ENV FLAT_DOMAIN="localhost"?)

You can use the provided image as is, but you do need to set the environment variables like FLAT_DOMAIN

This was the problem, now it works fine and indeed out of the box, thank you very much! I will try to adjust all the necessary variables and look forward to testing!

pirolen commented 2 years ago

Hm, don't seem to grasp how/if the settings.py and full.yaml config files should co-exist. I got an 'Internal server error' when I passed --env FLAT_CONFIG_DIR as in the installation docs

$ docker run -p 8080:80 -v /path/to/data:/data -v /path/to/config:/etc/flat --env FLAT_CONFIG_DIR=/etc/flat proycon/flat

I put full.yml next to settings.py

Should I want to just keep using settings.py, do I need to comment out the usual line?

Remove this when done configuring:

raise Exception("settings.py hasn't been configured yet!!") #remove me

Upon docker inspect:

    "Mounts": [
        {
            "Type": "bind",
            "Source": "/home/pirol/flat/data",
            "Destination": "/data",
            "Mode": "",
            "RW": true,
            "Propagation": "rprivate"
        },
        {
            "Type": "bind",
            "Source": "/home/pirol/flat/settings",
            "Destination": "/etc/flat",
            "Mode": "",
            "RW": true,
            "Propagation": "rprivate"
        }
    ],
  ...

"FLAT_CONFIG_DIR=/home/pirol/flat/settings/",

proycon commented 2 years ago

On 22-11-21 07:56, pirolen wrote:

Hm, don't seem to grasp how/if the settings.py and full.yaml config files should co-exist.

You shouldn't need to adapt settings.py anymore, passing a yaml configuration should be sufficient (and set $FLAT_DEFAULTCONFIGURATION).

I got an 'Internal server error' when I passed --env FLAT_CONFIG_DIR as in the installation docs

$ docker run -p 8080:80 -v /path/to/data:/data -v /path/to/config:/etc/flat --env FLAT_CONFIG_DIR=/etc/flat proycon/flat

Hmm, I assume you adapted /path/to to point to the right locations on the host system? (I guess it wouldn't have started if you didn't, but I better ask even the silly question just to be sure :) ). If you got an Internal Server Error, then you should have gotten more error output in the terminal where you launched docker run (or you may need to do docker logs $YOUR_CONTAINER_ID to get the full log output). I'm guessing it the error could have occurred because of a permission problem, but can't know for sure until you have the actual log output.

proycon commented 2 years ago

Should I want to just keep using settings.py, do I need to comment out the usual line?

#Remove this when done configuring:
#raise Exception("settings.py hasn't been configured yet!!") #remove me

Yes, but if you want your own settings.py then you also need to build your own docker container. There are some instructions in https://flat.readthedocs.io/en/latest/installation_guide.html#deployment-in-production for that too, but I'd suggest to just stick with the default settings.py, default docker build and do everything through the yaml file (because that's less work for you).

FLAT_CONFIG_DIR=/home/pirol/flat/settings/",

Ha! That's wrong... /home/pirol/flat/settings/ is the path on your host system, if you did -v /home/pirol/flat/settings:/etc/flat then the path inside the container is still /etc/flat and that should be the value of FLAT_CONFIG_DIR. I can see it may be a bit confusing.... Might be the cause of the HTTP 500 error too.

pirolen commented 2 years ago

It does not work with that value either, tried it before :-( The log is below.

Also, does the following make sense? -rw-r--r-- 1 pirol docker 7347 Nov 21 16:27 full.yml drwxr-xr-x 2 root root 37 Nov 18 15:43 pycache -rw-r--r-- 1 pirol docker 26076 Nov 21 17:56 settings.py


Starting foliadocserve... Applying migrations... 2022/11/21 17:13:50 [notice] 19#19: using the "epoll" event method 2022/11/21 17:13:50 [notice] 19#19: nginx/1.20.2 2022/11/21 17:13:50 [notice] 19#19: OS: Linux 5.4.0-132-generic 2022/11/21 17:13:50 [notice] 19#19: getrlimit(RLIMIT_NOFILE): 1048576:1048576 2022/11/21 17:13:50 [notice] 19#19: start worker processes 2022/11/21 17:13:50 [notice] 19#19: start worker process 21 2022/11/21 17:13:50 [notice] 19#19: start worker process 22 2022/11/21 17:13:50 [notice] 19#19: start worker process 23 2022/11/21 17:13:50 [notice] 19#19: start worker process 24 2022-11-21 17:13:51 - foliadocserve 0.7.7 2022-11-21 17:13:51 - Initialising document store in /data/flat.docroot [21/Nov/2022:17:13:51] ENGINE Listening for SIGTERM. [21/Nov/2022:17:13:51] ENGINE Listening for SIGHUP. [21/Nov/2022:17:13:51] ENGINE Listening for SIGUSR1. [21/Nov/2022:17:13:51] ENGINE Bus STARTING CherryPy Checker: The Application mounted at '' has an empty config.

2022-11-21 17:13:51 - Documents loaded: 0 [21/Nov/2022:17:13:51] ENGINE Started monitor thread 'Autoreloader'. [21/Nov/2022:17:13:51] ENGINE Serving on http://0.0.0.0:8080 [21/Nov/2022:17:13:51] ENGINE Bus STARTED Operations to perform: Synchronize unmigrated apps: editor, messages, metadata, staticfiles, structureeditor, viewer Apply all migrations: admin, auth, contenttypes, sessions, users Synchronizing apps without migrations: Creating tables... Running deferred SQL... Running migrations: No migrations to apply. Creating FLAT superuser and (re)setting password... Updating existing password for superuser. Starting FLAT via uwsgi... Starting uWSGI 2.0.19.1 (64bit) on [Mon Nov 21 17:13:52 2022] compiled with version: 10.3.1 20210921 on 05 April 2021 18:18:03 os: Linux-5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 nodename: 3de99bd2fb4e machine: x86_64 clock source: unix pcre jit disabled detected number of CPU cores: 4 current working directory: /etc/service/uwsgi detected binary path: /usr/sbin/uwsgi uWSGI running as root, you can use --uid/--gid/--chroot options setgid() to 100 set additional group 82 (www-data) set additional group 101 (nginx) setuid() to 100 your memory page size is 4096 bytes detected max file descriptor number: 1048576 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uwsgi socket 0 bound to TCP address 127.0.0.1:8888 fd 3 Python version: 3.9.7 (default, Nov 24 2021, 21:15:59) [GCC 10.3.1 20211027] Python main interpreter initialized at 0x7f5ceb0c0250 python threads support enabled your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 250128 bytes (244 KB) for 4 cores Operational MODE: preforking+threaded WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x7f5ceb0c0250 pid: 47 (default app) spawned uWSGI master process (pid: 47) spawned uWSGI worker 1 (pid: 48, cores: 2) spawned uWSGI worker 2 (pid: 50, cores: 2) 129.187.243.46 - - [21/Nov/2022:17:13:56 +0000] "GET /login/?next=/editor/flat/FA-b1_3_1_mwtext_vorbemerk_pp61_67_003 HTTP/1.1" 200 4147 "http://badwqsv-dev.srv.mwn.de:8080/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" "-" [pid: 50|app: 0|req: 1/1] 129.187.243.46 () {48 vars in 1115 bytes} [Mon Nov 21 17:13:56 2022] GET /login/?next=/editor/flat/FA-b1_3_1_mwtext_vorbemerk_pp61_67_003 => generated 4147 bytes in 228 msecs (HTTP/1.1 200) 4 headers in 263 bytes (1 switches on core 0) 2022-11-21 17:14:51 - Documents loaded: 0 2022/11/21 17:14:56 [info] 24#24: *2 client timed out (110: Operation timed out) while waiting for request, client: 129.187.243.46, server: 0.0.0.0:80 2022-11-21 17:15:51 - Documents loaded: 0 2022-11-21 17:16:51 - Documents loaded: 0 2022-11-21 17:17:51 - Documents loaded: 0 2022-11-21 17:18:51 - Documents loaded: 0 129.187.243.46 - - [21/Nov/2022:17:18:55 +0000] "GET /login/?next=/editor/flat/FA-b1_3_1_mwtext_vorbemerk_pp61_67_003 HTTP/1.1" 200 4147 "http://badwqsv-dev.srv.mwn.de:8080/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" "-" [pid: 48|app: 0|req: 1/2] 129.187.243.46 () {48 vars in 1115 bytes} [Mon Nov 21 17:18:55 2022] GET /login/?next=/editor/flat/FA-b1_3_1_mwtext_vorbemerk_pp61_67_003 => generated 4147 bytes in 228 msecs (HTTP/1.1 200) 4 headers in 263 bytes (1 switches on core 0)

proycon commented 2 years ago

Also, does the following make sense? -rw-r--r-- 1 pirol docker 7347 Nov 21 16:27 full.yml

World readable so should be okay yes.

It does not work with that value either, tried it before :-(

I don't see any HTTP 500 error in that log, what goes wrong? When checking http://badwqsv-dev.srv.mwn.de:8080/ as mentioned in the log, FLAT seems up and running, I even managed to login with the default credentials and see the document. (you might want to change the login credentials because that's not secure obviously). Also note that logging in over HTTP is not secure by definition, you need a reverse proxy to handle HTTPS ideally.

pirolen commented 2 years ago

That's odd since I did set with --env another password and login, and they also work :-o

The problem is that in case I pass the FLAT_CONFIG_DIR value to docker run, I get a server error. (This used to happen with ourold FLAT instance if something was incorrect in settings.py) So I cannot point the application to the yaml config file.

The container running now was started with this, as user pirol:

$ docker run --name flat -d --restart unless-stopped -p 8080:80 -v /home/pirol/flat/data:/data -v /home/pirol/flat/settings/:/etc/flat --env FLAT_DOMAIN=badwqsv-dev.srv.mwn.de --env FLAT_SECRET_KEY=$(uuidgen) --env FLAT_USER=xxxx--env FLAT_PASSWORD=xxx --env FLAT_ADMIN_NAME="xxx" --env FLAT_EMAIL=xxx --env FLAT_GIT_NAME=xxx --env FLAT_GIT_MAIL=xxxx proycon/flat

Shall I start a container with passing the FLAT_CONFIG_DIR, and then send the logs?