From 2404cf2e3ddf0456fe2cc1a399d6b1738c0798ad Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Tue, 9 Nov 2021 14:10:04 +0000 Subject: [PATCH 1/4] Fix for issue #1223 --- optional/fetchmail/Dockerfile | 3 +++ optional/fetchmail/fetchmail.py | 1 + setup/flavors/compose/docker-compose.yml | 2 ++ setup/flavors/stack/docker-compose.yml | 2 +- towncrier/newsfragments/1223.bugfix | 4 ++++ 5 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 towncrier/newsfragments/1223.bugfix diff --git a/optional/fetchmail/Dockerfile b/optional/fetchmail/Dockerfile index 995ec48f..0b3d4375 100644 --- a/optional/fetchmail/Dockerfile +++ b/optional/fetchmail/Dockerfile @@ -12,6 +12,9 @@ RUN apk add --no-cache \ RUN apk add --no-cache fetchmail ca-certificates openssl \ && pip3 install requests +RUN mkdir -p /data +RUN chown fetchmail:fetchmail /data + COPY fetchmail.py /fetchmail.py USER fetchmail diff --git a/optional/fetchmail/fetchmail.py b/optional/fetchmail/fetchmail.py index 4be3c2bd..3752c395 100755 --- a/optional/fetchmail/fetchmail.py +++ b/optional/fetchmail/fetchmail.py @@ -13,6 +13,7 @@ import traceback FETCHMAIL = """ fetchmail -N \ + --idfile /data/.fetchids \ --sslcertck --sslcertpath /etc/ssl/certs \ -f {} """ diff --git a/setup/flavors/compose/docker-compose.yml b/setup/flavors/compose/docker-compose.yml index 2675a2ab..5cdd6129 100644 --- a/setup/flavors/compose/docker-compose.yml +++ b/setup/flavors/compose/docker-compose.yml @@ -129,6 +129,8 @@ services: image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}fetchmail:${MAILU_VERSION:-{{ version }}} restart: always env_file: {{ env }} + volumes: + - "{{ root }}/fetchmail:/data" {% if resolver_enabled %} depends_on: - resolver diff --git a/setup/flavors/stack/docker-compose.yml b/setup/flavors/stack/docker-compose.yml index 24afa9f3..ae4f0022 100644 --- a/setup/flavors/stack/docker-compose.yml +++ b/setup/flavors/stack/docker-compose.yml @@ -110,7 +110,7 @@ services: image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}fetchmail:${MAILU_VERSION:-{{ version }}} env_file: {{ env }} volumes: - - "{{ root }}/data:/data" + - "{{ root }}/fetchmail:/data" deploy: replicas: 1 healthcheck: diff --git a/towncrier/newsfragments/1223.bugfix b/towncrier/newsfragments/1223.bugfix new file mode 100644 index 00000000..3c23d1a4 --- /dev/null +++ b/towncrier/newsfragments/1223.bugfix @@ -0,0 +1,4 @@ +Fixed fetchmail losing track of fetched emails upon container recreation. +The relevant fetchmail files are now retained in the /data folder (in the fetchmail image). +See the docker-compose.yml file for the relevant volume mapping. +If you already had your own mapping, you must double check the volume mapping and take action. From 92e65b33e03ba0bc881db28a7412489c572b732e Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Wed, 10 Nov 2021 09:07:03 +0000 Subject: [PATCH 2/4] Configure fetchmail to use idfile to keep track of messages. Run fetchmail as root. This is unfortunately required because all files are owned by root in the mailu data folder. In the future we must switch all images to running all all processes with a non-root user. --- optional/fetchmail/Dockerfile | 5 +---- optional/fetchmail/fetchmail.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/optional/fetchmail/Dockerfile b/optional/fetchmail/Dockerfile index 0b3d4375..068a5dce 100644 --- a/optional/fetchmail/Dockerfile +++ b/optional/fetchmail/Dockerfile @@ -13,10 +13,7 @@ RUN apk add --no-cache fetchmail ca-certificates openssl \ && pip3 install requests RUN mkdir -p /data -RUN chown fetchmail:fetchmail /data COPY fetchmail.py /fetchmail.py -USER fetchmail - -CMD ["/fetchmail.py"] +CMD ["/fetchmail.py"] \ No newline at end of file diff --git a/optional/fetchmail/fetchmail.py b/optional/fetchmail/fetchmail.py index 3752c395..f3b65fc0 100755 --- a/optional/fetchmail/fetchmail.py +++ b/optional/fetchmail/fetchmail.py @@ -13,7 +13,7 @@ import traceback FETCHMAIL = """ fetchmail -N \ - --idfile /data/.fetchids \ + --idfile /data/.fetchids --uidl \ --sslcertck --sslcertpath /etc/ssl/certs \ -f {} """ From c81aa67dfa9c8d01cb9d55a7bd8c216518d74f98 Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Wed, 10 Nov 2021 13:08:33 +0000 Subject: [PATCH 3/4] Use a better location for storing the fetchmail data. --- setup/flavors/compose/docker-compose.yml | 2 +- setup/flavors/stack/docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup/flavors/compose/docker-compose.yml b/setup/flavors/compose/docker-compose.yml index 5cdd6129..18a881b8 100644 --- a/setup/flavors/compose/docker-compose.yml +++ b/setup/flavors/compose/docker-compose.yml @@ -130,7 +130,7 @@ services: restart: always env_file: {{ env }} volumes: - - "{{ root }}/fetchmail:/data" + - "{{ root }}/data/fetchmail:/data" {% if resolver_enabled %} depends_on: - resolver diff --git a/setup/flavors/stack/docker-compose.yml b/setup/flavors/stack/docker-compose.yml index ae4f0022..0c744d7e 100644 --- a/setup/flavors/stack/docker-compose.yml +++ b/setup/flavors/stack/docker-compose.yml @@ -110,7 +110,7 @@ services: image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}fetchmail:${MAILU_VERSION:-{{ version }}} env_file: {{ env }} volumes: - - "{{ root }}/fetchmail:/data" + - "{{ root }}/data/fetchmail:/data" deploy: replicas: 1 healthcheck: From d7d02152bbc55f1d26dca7c245d3224786a2ed4a Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Sat, 13 Nov 2021 14:40:22 +0000 Subject: [PATCH 4/4] Make fetchid file not hidden. --- optional/fetchmail/fetchmail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optional/fetchmail/fetchmail.py b/optional/fetchmail/fetchmail.py index f3b65fc0..5459de59 100755 --- a/optional/fetchmail/fetchmail.py +++ b/optional/fetchmail/fetchmail.py @@ -13,7 +13,7 @@ import traceback FETCHMAIL = """ fetchmail -N \ - --idfile /data/.fetchids --uidl \ + --idfile /data/fetchids --uidl \ --sslcertck --sslcertpath /etc/ssl/certs \ -f {} """