quru / qis

Dynamic image server for web and print
https://quruimageserver.com
GNU Affero General Public License v3.0
89 stars 7 forks source link

Error running docker setup on Ubuntu #28

Closed martnst closed 5 years ago

martnst commented 5 years ago

Looks like there is a missing configuration in the docker image?

Logs:

$ docker ps | grep as
59de577458a1        quru/qis-as          "/run-qis.sh"         3 hours ago         Up 3 hours (unhealthy)   0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   qis-via-docker_qis_as_1

$ docker logs 59de577458a1
Performing one-time initialization
Waiting 30 seconds for the Postgres database to be created
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.***.***.3. Set the 'ServerName' directive globally to suppress this message

$ docker -v
Docker version 19.03.2, build 6a30dfc

$ curl --insecure -i https://localhost
HTTP/1.1 500 Internal Server Error
Date: Wed, 02 Oct 2019 11:50:37 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 607
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at 
 [no address given] to inform them of the time this error occurred,
 and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at localhost Port 443</address>
</body></html>
fozcode commented 5 years ago

Hi there! Have you created a data directory and run the associated Postgres database container? There are instructions here on how to get going with the Docker images and docker-compose file:

https://github.com/quru/qis/blob/master/doc/running.md#docker

But briefly a minimal setup is:

$ mkdir qis
$ cd qis
$ mkdir data
$ docker pull quru/qis-as
$ docker pull quru/qis-postgres
$ docker pull quru/qis-memcached
$ wget https://raw.githubusercontent.com/quru/qis/master/deploy/docker/docker-compose.yml
<remove the "build" lines from docker-compose.yml>
$ echo -e "QIS_HOSTNAME=localhost\nQIS_DATA_DIR=./data" > .env
$ docker-compose up -d
<wait 30 seconds -- first time around only>

$ curl --insecure https://localhost/
<!DOCTYPE html>
<html>
...[snip]

$ grep 'admin user' data/logs/qis/qis.log
2019-10-02 13:34:10,221 qis_31     INFO     Created default admin user with password 831z96M1wu

<browse to https://localhost/ and login as admin with password 831z96M1wu>
martnst commented 5 years ago

Hi, yeah actually I faced an issue of The PGDATA directory is not writable for the container from the qis_db as I tried to set it up on Ubuntu 18.04 LTS with docker-compose.

Because of this error I then tried installing postgres natively on Ubuntu on. Then hooking in via adding 127.0.0.1 qis_db to /etc/hosts and network_mode: host in the docker-compose.yml (also removing the qis_db service from it). Finally I was able to have the qis-as up and browse the admin login page. However there is no data/logs/qis/qis.log file.

There are such logs in data/logs/apache/error.log:

[Wed Oct 02 12:58:42.220279 2019] [wsgi:error] [pid 161:tid 139730637281024] Stats server exited: [Errno 13] Permission denied: '/opt/qis/images/.metadata'
[Wed Oct 02 12:58:42.240174 2019] [wsgi:error] [pid 163:tid 139730637281024] Task server exited: [Errno 13] Permission denied: '/opt/qis/images/.metadata'

So all in all I think there is some permission setup going wrong or missing.

fozcode commented 5 years ago

OK I understand. The difference is I'm running Docker for Mac whereas you're running proper Docker on Linux. On Linux when mounting a directory from the host into the container, the directory on the host must be owned by the correct user ID otherwise you'll get these "permission denied" errors. The documentation is missing this part. I'll find out what the correct IDs should be and update the docs with the fix.

fozcode commented 5 years ago

I have revised the running.md document with the additional setup instructions, briefly:

$ mkdir -p qis/data
$ cd qis
$ mkdir data/data && sudo chown 105:109 data/data
$ mkdir data/images && sudo chown 999:999 data/images
$ mkdir -p data/logs/qis && sudo chown 999:999 data/logs/qis

with the rest being as before.

This fixes the permissions errors. But in testing this I've found an intermittent timing problem whereby sometimes the first few log file entries are lost. Since the first logs include the generated password for logging in, this is a problem. You might get lucky and not hit this, but there's another fix to come yet.

fozcode commented 5 years ago

Hopefully these issues are all fixed now. Please can you run a docker pull quru/qis-as to bring down the latest Docker image and try again?

martnst commented 5 years ago

@fozcode Thanks for the updates. It works without issues now. 🙂