12 Commits

Author SHA1 Message Date
b5692c03d9 fix: database port
All checks were successful
continuous-integration/drone/push Build is passing
2022-01-21 23:32:09 +01:00
fe8bf5d73c fix(Makefile): use official container image name 2022-01-21 23:31:15 +01:00
feee56b98c fix(Dockerfile): upgrade packages 2022-01-21 23:30:45 +01:00
d6536071ef fix: log to stdout 2022-01-21 23:30:28 +01:00
66a537767f fix(ci): dependencies and conditions
All checks were successful
continuous-integration/drone/push Build is passing
2021-10-12 21:59:55 +02:00
0de75ab85d doc(README): image name
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-26 21:00:12 +02:00
4b81be1cb6 doc(README): badges
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-26 20:59:10 +02:00
3e22105622 doc(README): headline
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-26 20:49:02 +02:00
f2e7f6e99c fix: change name of the git repository
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-26 17:29:14 +02:00
514f2d1b5e fix(README): require database scheme of postfixadmin
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-12 19:59:12 +02:00
389bfb967c fix(README): describe environment variables
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-12 19:54:20 +02:00
8d48d4d458 fix: support database port
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-11 13:43:29 +02:00
7 changed files with 110 additions and 51 deletions

View File

@ -11,7 +11,7 @@ steps:
- name: markdown lint - name: markdown lint
commands: commands:
- markdownlint *.md - markdownlint *.md
image: docker.io/volkerraschek/markdownlint:0.28.1 image: docker.io/volkerraschek/markdownlint:0.29.0
resources: resources:
limits: limits:
cpu: 50 cpu: 50
@ -41,6 +41,7 @@ trigger:
event: event:
exclude: exclude:
- tag - tag
--- ---
kind: pipeline kind: pipeline
type: docker type: docker
@ -57,7 +58,7 @@ steps:
dockerfile: Dockerfile dockerfile: Dockerfile
auto_tag: false auto_tag: false
tags: latest-amd64 tags: latest-amd64
repo: volkerraschek/fetchmail repo: volkerraschek/postfixadmin-fetchmail
username: username:
from_secret: container_image_registry_user from_secret: container_image_registry_user
password: password:
@ -66,9 +67,6 @@ steps:
volumes: volumes:
- name: docker_socket - name: docker_socket
path: /var/run/docker.sock path: /var/run/docker.sock
when:
branch:
- master
- name: notify - name: notify
image: drillster/drone-email image: drillster/drone-email
@ -91,10 +89,17 @@ volumes:
host: host:
path: /var/run/docker.sock path: /var/run/docker.sock
depends_on:
- linter
trigger: trigger:
branch:
- master
event: event:
exclude: - cron
- tag - push
repo:
- volker.raschek/postfixadmin-fetchmail-docker
--- ---
kind: pipeline kind: pipeline
@ -112,15 +117,12 @@ steps:
dockerfile: Dockerfile dockerfile: Dockerfile
auto_tag: false auto_tag: false
tags: latest-armv7 tags: latest-armv7
repo: volkerraschek/fetchmail repo: volkerraschek/postfixadmin-fetchmail
username: username:
from_secret: container_image_registry_user from_secret: container_image_registry_user
password: password:
from_secret: container_image_registry_password from_secret: container_image_registry_password
no_cache: true no_cache: true
when:
branch:
- master
- name: notify - name: notify
image: drillster/drone-email image: drillster/drone-email
@ -146,10 +148,17 @@ volumes:
host: host:
path: /var/run/docker.sock path: /var/run/docker.sock
depends_on:
- linter
trigger: trigger:
branch:
- master
event: event:
exclude: - cron
- tag - push
repo:
- volker.raschek/postfixadmin-fetchmail-docker
--- ---
kind: pipeline kind: pipeline
@ -193,9 +202,13 @@ depends_on:
- latest-armv7 - latest-armv7
trigger: trigger:
branch:
- master
event: event:
exclude: - cron
- tag - push
repo:
- volker.raschek/postfixadmin-fetchmail-docker
--- ---
kind: pipeline kind: pipeline
@ -213,7 +226,7 @@ steps:
dockerfile: Dockerfile dockerfile: Dockerfile
auto_tag: true auto_tag: true
auto_tag_suffix: amd64 auto_tag_suffix: amd64
repo: volkerraschek/fetchmail repo: volkerraschek/postfixadmin-fetchmail
username: username:
from_secret: container_image_registry_user from_secret: container_image_registry_user
password: password:
@ -248,7 +261,7 @@ trigger:
event: event:
- tag - tag
repo: repo:
- volker.raschek/fetchmail-docker - volker.raschek/postfixadmin-fetchmail-docker
--- ---
kind: pipeline kind: pipeline
@ -266,7 +279,7 @@ steps:
dockerfile: Dockerfile dockerfile: Dockerfile
auto_tag: true auto_tag: true
auto_tag_suffix: armv7 auto_tag_suffix: armv7
repo: volkerraschek/fetchmail repo: volkerraschek/postfixadmin-fetchmail
username: username:
from_secret: container_image_registry_user from_secret: container_image_registry_user
password: password:
@ -301,7 +314,7 @@ trigger:
event: event:
- tag - tag
repo: repo:
- volker.raschek/fetchmail-docker - volker.raschek/postfixadmin-fetchmail-docker
--- ---
kind: pipeline kind: pipeline
@ -348,7 +361,7 @@ trigger:
event: event:
- tag - tag
repo: repo:
- volker.raschek/fetchmail-docker - volker.raschek/postfixadmin-fetchmail-docker
--- ---
kind: pipeline kind: pipeline
@ -368,7 +381,7 @@ steps:
memory: 25M memory: 25M
settings: settings:
branch: master branch: master
remote: ssh://git@github.com/volker-raschek/fetchmail-docker.git remote: ssh://git@github.com/volker-raschek/postfixadmin-fetchmail-docker.git
force: true force: true
ssh_key: ssh_key:
from_secret: ssh_key from_secret: ssh_key
@ -393,8 +406,14 @@ steps:
- changed - changed
- failure - failure
depends_on:
- latest-manifest
trigger: trigger:
branch:
- master
event: event:
- cron
- push - push
repo: repo:
- volker.raschek/fetchmail-docker - volker.raschek/postfixadmin-fetchmail-docker

View File

@ -1,6 +1,7 @@
FROM docker.io/library/alpine:3.11.2 FROM docker.io/library/alpine:3.11.2
RUN echo "http://dl-3.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories RUN echo "http://dl-3.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories
RUN apk upgrade
RUN apk add --update perl perl-lockfile-simple perl-dbi perl-dbd-pg perl-dbd-mysql fetchmail RUN apk add --update perl perl-lockfile-simple perl-dbi perl-dbd-pg perl-dbd-mysql fetchmail
RUN mkdir --parents /run/fetchmail RUN mkdir --parents /run/fetchmail

View File

@ -9,7 +9,7 @@ FETCHMAIL_IMAGE_REGISTRY_NAME:=docker.io
FETCHMAIL_IMAGE_REGISTRY_USER:=volkerraschek FETCHMAIL_IMAGE_REGISTRY_USER:=volkerraschek
FETCHMAIL_IMAGE_NAMESPACE?=${FETCHMAIL_IMAGE_REGISTRY_USER} FETCHMAIL_IMAGE_NAMESPACE?=${FETCHMAIL_IMAGE_REGISTRY_USER}
FETCHMAIL_IMAGE_NAME:=fetchmail FETCHMAIL_IMAGE_NAME:=postfixadmin-fetchmail
FETCHMAIL_IMAGE_VERSION?=latest FETCHMAIL_IMAGE_VERSION?=latest
FETCHMAIL_IMAGE_FULLY_QUALIFIED=${FETCHMAIL_IMAGE_REGISTRY_NAME}/${FETCHMAIL_IMAGE_NAMESPACE}/${FETCHMAIL_IMAGE_NAME}:${FETCHMAIL_IMAGE_VERSION} FETCHMAIL_IMAGE_FULLY_QUALIFIED=${FETCHMAIL_IMAGE_REGISTRY_NAME}/${FETCHMAIL_IMAGE_NAMESPACE}/${FETCHMAIL_IMAGE_NAME}:${FETCHMAIL_IMAGE_VERSION}
FETCHMAIL_IMAGE_UNQUALIFIED=${FETCHMAIL_IMAGE_NAMESPACE}/${FETCHMAIL_IMAGE_NAME}:${FETCHMAIL_IMAGE_VERSION} FETCHMAIL_IMAGE_UNQUALIFIED=${FETCHMAIL_IMAGE_NAMESPACE}/${FETCHMAIL_IMAGE_NAME}:${FETCHMAIL_IMAGE_VERSION}

View File

@ -1,15 +1,17 @@
# fetchmail-docker # PostfixAdmin's fetchmail
[![Build Status](https://drone.cryptic.systems/api/badges/volker.raschek/fetchmail-docker/status.svg)](https://drone.cryptic.systems/volker.raschek/fetchmail-docker) [![Build Status](https://drone.cryptic.systems/api/badges/volker.raschek/postfixadmin-fetchmail-docker/status.svg)](https://drone.cryptic.systems/volker.raschek/postfixadmin-fetchmail-docker)
[![Docker Pulls](https://img.shields.io/docker/pulls/volkerraschek/fetchmail)](https://hub.docker.com/r/volkerraschek/fetchmail) [![Docker Pulls](https://img.shields.io/docker/pulls/volkerraschek/postfixadmin-fetchmail)](https://hub.docker.com/r/volkerraschek/postfixadmin-fetchmail)
This project contains all sources to build the container image This project contains all sources to build the container image
`docker.io/volkerraschek/fetchmail`. The primary goal of the image is to fetch `docker.io/volkerraschek/postfixadmin-fetchmail`. The primary goal of the image
mails from external servers and forward them to on local running mail server. is to fetch mails from external servers and forward them to on local running
mail server.
The configuration file will be automatically generated based on information from The configuration file will be automatically generated based on information from
a database. As table the fetchmail table from the schema of a supported database backend of
[postfixadmin](https://github.com/postfixadmin/postfixadmin) is expected. [postfixadmin](https://github.com/postfixadmin/postfixadmin). The information
are stored in the table `fetchmail` of the database scheme of PostfixAdmin.
## Usage ## Usage
@ -25,6 +27,7 @@ $ docker run \
--rm \ --rm \
--env DATABASE_TYPE: Pg \ --env DATABASE_TYPE: Pg \
--env DATABASE_HOST: postgres \ --env DATABASE_HOST: postgres \
--env DATABASE_PORT: 5432 \
--env DATABASE_NAME: postgres \ --env DATABASE_NAME: postgres \
--env DATABASE_USER: fetchmail \ --env DATABASE_USER: fetchmail \
--env DATABASE_PASSWORD: MySecretPassword \ --env DATABASE_PASSWORD: MySecretPassword \
@ -39,6 +42,7 @@ $ docker run \
--rm \ --rm \
--env DATABASE_TYPE: my \ --env DATABASE_TYPE: my \
--env DATABASE_HOST: root \ --env DATABASE_HOST: root \
--env DATABASE_PORT: 3306 \
--env DATABASE_NAME: mysql \ --env DATABASE_NAME: mysql \
--env DATABASE_USER: fetchmail \ --env DATABASE_USER: fetchmail \
--env DATABASE_PASSWORD: MySecretPassword \ --env DATABASE_PASSWORD: MySecretPassword \
@ -62,18 +66,47 @@ services:
environment: environment:
- DATABASE_TYPE=${DATABASE_TYPE} - DATABASE_TYPE=${DATABASE_TYPE}
- DATABASE_HOST=${DATABASE_HOST} - DATABASE_HOST=${DATABASE_HOST}
- DATABASE_HOST=${DATABASE_PORT}
- DATABASE_NAME=${DATABASE_NAME} - DATABASE_NAME=${DATABASE_NAME}
- DATABASE_USER=${DATABASE_USER} - DATABASE_USER=${DATABASE_USER}
- DATABASE_PASSWORD=${DATABASE_PASSWORD} - DATABASE_PASSWORD=${DATABASE_PASSWORD}
network_mode: host network_mode: host
``` ```
## Build container image manually ## Environment variables
To build the images manually check out the repository on ### DATABASE_TYPE
[github](https://github.com/volker-raschek/fetchmail-docker) with git and use
the make command to build the container image.
```bash Currently will be only postgres, mysql and mariadb supported. About the
make container-image/build environment variable `DATABASE_TYPE` can the backend type defined. The value is
``` required.
| database type | value |
| ------------- | ----- |
| mysql/mariadb | `my` |
| postgres | `Pg` |
### DATABASE_USER
The environment variable `DATABASE_USER` is undefined and required. The value
contains the database user which one fetchmail use to login.
### DATABASE_PASSWORD
The environment variable `DATABASE_PASSWORD` is undefined and required. The value
contains the password of the database user which one fetchmail use to login.
### DATABASE_HOST
The environment variable `DATABASE_HOST` is undefined and required. The value
contains the DNS name or IP address of the host, where the database is hosted.
### DATABASE_PORT
The environment variable `DATABASE_PORT` is undefined and required. The value
contains the port of the host, where the database is listen on.
### DATABASE_NAME
The environment variable `DATABASE_NAME` is undefined and required. The value
contains the name of the database against which should be logged in.

View File

@ -1,12 +1,13 @@
version: "3" version: "3"
services: services:
fetchmail: postfixadmin-fetchmail:
container_name: fetchmail container_name: postfixadmin-fetchmail
image: volkerraschek/fetchmail-docker:latest image: docker.io/volkerraschek/postfixadmin-fetchmail:latest
environment: environment:
- DATABASE_TYPE=${DATABASE_TYPE} - DATABASE_TYPE=${DATABASE_TYPE}
- DATABASE_HOST=${DATABASE_HOST}
- DATABASE_NAME=${DATABASE_NAME}
- DATABASE_USER=${DATABASE_USER} - DATABASE_USER=${DATABASE_USER}
- DATABASE_PASSWORD=${DATABASE_PASSWORD} - DATABASE_PASSWORD=${DATABASE_PASSWORD}
- DATABASE_HOST=${DATABASE_HOST}
- DATABASE_PORT=${DATABASE_PORT}
- DATABASE_NAME=${DATABASE_NAME}
network_mode: host network_mode: host

View File

@ -15,10 +15,11 @@ use LockFile::Simple qw(lock trylock unlock);
# database backend - uncomment one of these # database backend - uncomment one of these
our $db_type=$ENV{'DATABASE_TYPE'}; our $db_type=$ENV{'DATABASE_TYPE'};
our $db_host=$ENV{'DATABASE_HOST'};
our $db_name=$ENV{'DATABASE_NAME'};
our $db_username=$ENV{'DATABASE_USER'}; our $db_username=$ENV{'DATABASE_USER'};
our $db_password=$ENV{'DATABASE_PASSWORD'}; our $db_password=$ENV{'DATABASE_PASSWORD'};
our $db_host=$ENV{'DATABASE_HOST'};
our $db_port=$ENV{'DATABASE_PORT'};
our $db_name=$ENV{'DATABASE_NAME'};
# instead of changing this script, you can put your settings to /etc/mail/postfixadmin/fetchmail.conf # instead of changing this script, you can put your settings to /etc/mail/postfixadmin/fetchmail.conf
# just use perl syntax there to fill the variables listed above (without the "our" keyword). Example: # just use perl syntax there to fill the variables listed above (without the "our" keyword). Example:
@ -34,7 +35,7 @@ openlog("fetchmail-all", "pid", "mail");
sub log_and_die { sub log_and_die {
my($message) = @_; my($message) = @_;
syslog("err", $message); printf "err: %s\n", $message;
die $message; die $message;
} }
@ -60,7 +61,7 @@ if (-e $configfile) {
} }
if($db_type eq "Pg" || $db_type eq "mysql") { if($db_type eq "Pg" || $db_type eq "mysql") {
$dsn = "DBI:$db_type:database=$db_name;host=$db_host"; $dsn = "DBI:$db_type:database=$db_name;host=$db_host;port=$db_port";
} else { } else {
log_and_die "unsupported db_type $db_type"; log_and_die "unsupported db_type $db_type";
} }
@ -89,7 +90,7 @@ my (%config);
map{ map{
my ($id,$mailbox,$src_server,$src_auth,$src_user,$src_password,$src_folder,$fetchall,$keep,$protocol,$mda,$extra_options,$usessl,$sslcertck,$sslcertpath,$sslfingerprint)=@$_; my ($id,$mailbox,$src_server,$src_auth,$src_user,$src_password,$src_folder,$fetchall,$keep,$protocol,$mda,$extra_options,$usessl,$sslcertck,$sslcertpath,$sslfingerprint)=@$_;
syslog("info","fetch ${src_user}@${src_server} for ${mailbox}"); printf "info: fetch %s@%s for %s\n", ${src_user}, ${src_server}, ${mailbox};
$cmd="user '${src_user}' there with password '".decode_base64($src_password)."'"; $cmd="user '${src_user}' there with password '".decode_base64($src_password)."'";
$cmd.=" folder '${src_folder}'" if ($src_folder); $cmd.=" folder '${src_folder}'" if ($src_folder);
@ -111,7 +112,8 @@ set postmaster "postmaster"
set nobouncemail set nobouncemail
set no spambounce set no spambounce
set properties "" set properties ""
set syslog set no syslog
set logfile /dev/stdout
poll ${src_server} with proto ${protocol} poll ${src_server} with proto ${protocol}
$cmd $cmd
@ -128,6 +130,9 @@ TXT
$sql="UPDATE fetchmail SET returned_text=".$dbh->quote($ret).", date=now() WHERE id=".$id; $sql="UPDATE fetchmail SET returned_text=".$dbh->quote($ret).", date=now() WHERE id=".$id;
$dbh->do($sql); $dbh->do($sql);
printf "info: fetched mails of %s@%s for %s\n", ${src_user}, ${src_server}, ${mailbox};
}@{$dbh->selectall_arrayref($sql)}; }@{$dbh->selectall_arrayref($sql)};
$lockmgr->unlock($lock_file); $lockmgr->unlock($lock_file);

View File

@ -1,4 +1,4 @@
image: volkerraschek/fetchmail:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} image: volkerraschek/postfixadmin-fetchmail:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}} {{#if build.tags}}
tags: tags:
{{#each build.tags}} {{#each build.tags}}
@ -8,12 +8,12 @@ tags:
{{/if}} {{/if}}
manifests: manifests:
- -
image: volkerraschek/fetchmail:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-amd64 image: volkerraschek/postfixadmin-fetchmail:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-amd64
platform: platform:
architecture: amd64 architecture: amd64
os: linux os: linux
- -
image: volkerraschek/fetchmail:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-armv7 image: volkerraschek/postfixadmin-fetchmail:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-armv7
platform: platform:
architecture: arm architecture: arm
os: linux os: linux