diff --git a/.drone.yml b/.drone.yml index 8dab7ff..5802768 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,4 +5,4 @@ name: exec-debian-memiks steps: - name: docker build commands: - - docker build -t 'opensmtpd-debian' . + - docker build -t 'opensmtpd-alpine' . diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..a2e71e2 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,36 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "docker build", + "type": "shell", + "command": "docker build -t ${workspaceFolderBasename} . ", + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "into docker image", + "type": "shell", + "windows":{"command": "c:/Program Files/Docker/Docker/Resources/bin/docker"}, + "args": [ + "run", + "--rm", + "-it", + "${input:dockerID}", + "bash" + ] + } + ], + "inputs": [ + { + "id":"dockerID", + "description": "docker id to deep into", + "default": "ex: b950ac16e056", + "type": "promptString" + } + ] +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6d2a842..20c0b06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,44 @@ -FROM debian +FROM alpine LABEL Maintainer="Memiks " \ - Description="Lightweight container with OpenSMTPD on Debian Linux." + Description="Lightweight container with OpenSMTPD on Alpine Linux." -# Install packages -RUN apt -qy update +# Allow container to expose ports at runtime, if necessary +# https://docs.docker.com/engine/reference/#expose +EXPOSE 25 +EXPOSE 465 +EXPOSE 587 -RUN apt-get install -qy \ - build-essential linux-libc-dev \ - autoconf automake autoconf bison libevent-dev libasr-dev cmake libtool pkg-config \ - git curl gawk tar bzip2 ncompress xz-utils tree wget - -WORKDIR /tmp -ENV LIBRESSLVERSION=libressl-3.0.2 -RUN wget -O ${LIBRESSLVERSION}.tar.gz https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/${LIBRESSLVERSION}.tar.gz -RUN tar xf ${LIBRESSLVERSION}.tar.gz - -WORKDIR /tmp/${LIBRESSLVERSION} - -RUN ./configure --prefix=/usr/local/libressl --with-openssldir=/usr/local/libressl -RUN make && make install +# install necessary packages +RUN apk add --no-cache \ + autoconf \ + automake \ + bison \ + ca-certificates \ + fts-dev \ + gcc \ + fts \ + libasr-dev \ + libevent-dev \ + libtool \ + libtool \ + linux-pam-dev \ + make \ + musl-dev \ + openssl \ + openssl-dev \ + zlib-dev \ + git + +# create users and directories +# note: alpine uses busybox and useradd is not available there +# also long flags are not available too, so sorry for the +RUN mkdir -p /var/lib/opensmtpd/empty \ + && adduser _smtpd -h /var/lib/opensmtpd/empty/ -D -H -s /bin/false \ + && adduser _smtpq -h /var/lib/opensmtpd/empty/ -D -H -s /bin/false \ + && mkdir -p /var/spool/smtpd \ + && mkdir -p /var/mail \ + && mkdir -p /etc/mail \ + && chmod 711 /var/spool/smtpd WORKDIR /tmp RUN git clone -b portable git://github.com/OpenSMTPD/OpenSMTPD.git opensmtpd @@ -26,11 +46,27 @@ RUN git clone -b portable git://github.com/OpenSMTPD/OpenSMTPD.git opensmtpd WORKDIR /tmp/opensmtpd RUN ./bootstrap \ && ./configure \ - --with-libssl=/usr/local/libressl + --prefix=/usr \ + --sbindir=/usr/bin \ + --libexecdir=/usr/lib/smtpd \ + --sysconfdir=/etc/smtpd \ + --with-user-smtpd=smtpd \ + --with-user-queue=smtpq \ + --with-group-queue=smtpq \ + --with-gnu-ld \ + --with-auth-pam RUN make && make install +#RUN etc/aliases /etc/mail/aliases + +RUN addgroup smtpq +RUN adduser -D -S -G smtpq smtpq +RUN addgroup smtpd +RUN adduser -D -S -G smtpd smtpd + +USER smtpd + +WORKDIR /etc/smtpd # Override shell for bash-y debugging goodness SHELL ["/bin/bash", "-exc"] - -WORKDIR /tmp \ No newline at end of file