jsuto / piler

Email archiving application
https://www.mailpiler.org/
Other
75 stars 9 forks source link

cp: cannot stat '/etc/piler/piler-nginx.conf.dist': No such file or directory #31

Closed ykorzikowski closed 6 months ago

ykorzikowski commented 6 months ago

When I mount /etc/piler into the container, there is no more /etc/piler/piler-nginx.conf.dist you can use in the init script.

https://github.com/jsuto/piler/blob/bf28ea314b127086a5275b121a1fdeb4466c1d3b/docker/start.sh#L82

This results into the following error when initially spinning up the container:

cp: cannot stat '/etc/piler/piler-nginx.conf.dist': No such file or directory

I can not figure out where this file comes from. Can you maybe adjust this or add a bit more docs :)

This would be lovely.

Edit: I achieved this by

ansible@lxc-mailpiler:/mnt/data/piler/etc$ docker run sutoj/piler:1.4.5 cat /etc/piler/piler.conf.dist
ansible@lxc-mailpiler:/mnt/data/piler/etc$ docker run sutoj/piler:1.4.5 cat /etc/piler/piler-nginx.conf.dist

Maybe you copy the files in the docker build to another directory like /etc/examples or so.

jsuto commented 6 months ago

Well, they come from the image. The start.sh script only tries to copy piler-nginx.conf.dist if no piler-nginx.conf file exists.

This is what the image contains:

docker run --rm --name aaa -ti sutoj/piler:1.4.5 bash

root@b30c3684300c:/# ls -la /etc/piler/
total 52
drwxr-xr-x 3 root  root  4096 May  7 20:41 .
drwxr-xr-x 1 root  root  4096 May  7 20:41 ..
-rw-r--r-- 1 root  root     0 Apr 14 06:24 MANTICORE
-rw-r--r-- 1 root  piler  379 Apr 14 06:23 config-site.dist.php
-rwxr-xr-x 1 root  root  7921 Apr 14 06:24 manticore.conf
-rwxr-xr-x 1 root  piler 7921 Apr 14 06:23 manticore.conf.dist
-rw-r--r-- 1 root  root  2552 Apr 14 06:23 piler-nginx.conf.dist
-rw-r----- 1 root  piler 1328 Apr 14 06:23 piler.conf.dist
drwxr-xr-x 2 piler piler 4096 May  7 20:41 sites
-rwxr-xr-x 1 root  piler 8823 Apr 14 06:23 sphinx.conf.dist

docker run --rm sutoj/piler:1.4.5 head /etc/piler/piler-nginx.conf.dist

server {
        server_name PILER_HOST;

        root /var/piler/www;

        server_tokens off;

        add_header X-XSS-Protection "1; mode=block";
        add_header X-Content-Type-Options "nosniff";

Try pulling the image again, let's see if it helps.

jsuto commented 6 months ago

Cannot reproduce the issue, also no further input from user.

th-2021 commented 6 months ago

I had the same issue. In my case It was related to kubernetes. The volume mount in kubernetes is different from docker. In kubernetes you have to create an initcontainer that copies the data from the image to the volume.

jsuto commented 6 months ago

It's good to know. Can you share a deployment yaml how you did it?

neiaberau commented 4 months ago

In case someone else has the same issue, in some configurations changes in docker-compose it is reproducible, here is one possible reason:

I had the same issue after I adapted docker compose, as I tried to use host mounted volumes and not actual docker volumes. there is a slight difference between those. docker volume intialize with whatever is in the image, whereas bind mounted volumes intialize empty. the start script expects the directories of the volumes to be prefilled.

I did this to intialize: docker cp $(docker create --name tmp_copy sutoj/piler:1.4.5):/etc/piler piler_etc docker rm tmp_copy

mutschler commented 3 months ago

Well, they come from the image.

yeah... but they can't be accessed if you bind mount /etc/piler to a local directory.

there is a slight difference between those. docker volume intialize with whatever is in the image, whereas bind mounted volumes intialize empty. the start script expects the directories of the volumes to be prefilled.

this!

jsuto commented 3 months ago

What's the problem with docker volumes that you don't want to use it?

th-2021 commented 3 months ago

I'm using kubernetes volumes. And the difference is that they are empty. So mounting on /etc gives an empty /etc. In this case the startup script should populate these mounted volumes

Am 15. Juli 2024 12:15:56 MESZ schrieb jsuto @.***>:

What's the problem with docker volumes that you don't want to use it?

-- Reply to this email directly or view it on GitHub: https://github.com/jsuto/piler/issues/31#issuecomment-2228155615 You are receiving this because you commented.

Message ID: @.***>

jsuto commented 3 months ago

OK, fine. I've built a test image (https://github.com/jsuto/piler/pull/89), sutoj/piler:test, please try it.