From f76b0306c784aa41fe0bcee2fceb43e3d97c21f6 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 23 Jul 2017 17:56:38 +1000 Subject: [PATCH] Initial release --- .gitlab-ci.yml | 44 ++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 29 +++++++++++++++++++++++++++++ init | 25 +++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile create mode 100755 init diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..477f523 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,44 @@ +image: docker:latest + +stages: +- test +- build + +variables: + VERSION: ${CI_COMMIT_TAG:-latest} + CACHETAG: build + DOCKER_REGISTRY: registry.leenooks.net + DOCKER_HOST: tcp://${DOCKER_REGISTRY}-leenooks-ci-docker:2375 + +services: +- ${DOCKER_REGISTRY}/leenooks/ci-docker:dind + +before_script: +- docker info +- docker version +- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN ${DOCKER_REGISTRY} +- echo "CI_PROJECT_PATH ${CI_PROJECT_PATH} CI_COMMIT_TAG ${CI_COMMIT_TAG} CI_COMMIT_REF_NAME ${CI_COMMIT_REF_NAME}" +- echo "CI_REGISTRY ${CI_REGISTRY} CI_REGISTRY_IMAGE ${CI_REGISTRY_IMAGE} CI ${CI}" + +test: + stage: test + script: + - cat /etc/hosts + - env|sort + - docker build -t ${CI_REGISTRY_IMAGE}:${VERSION} . + - docker images + only: + - debug + +build: + stage: build + script: + - chmod 500 init + - docker pull ${CI_REGISTRY_IMAGE}:${CACHETAG} || true + - docker build --cache-from ${CI_REGISTRY_IMAGE}:${CACHETAG} -t ${CI_REGISTRY_IMAGE}:${VERSION} -t ${CI_REGISTRY_IMAGE}:${CACHETAG} . + - docker push ${CI_REGISTRY_IMAGE}:${VERSION} + - docker push ${CI_REGISTRY_IMAGE}:${CACHETAG} + tags: + - docker + only: + - master diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..72dc952 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# NAME leenooks/smtp +# VERSION latest +# BUILD docker build -t="leenooks/smtp" . + +FROM registry.leenooks.net/leenooks/base:7 + +RUN yum -y install epel-release && yum clean all + +# EPEL & Leenooks packages +RUN yum -y install \ + make \ + m4 \ + sendmail \ + sendmail-cf \ + ln-mail-server \ + milter-greylist \ + && yum clean all + +# ln-mail-client \ + +RUN useradd -rc "HUB Mail Relay" -M relay -NG mail -s /sbin/nologin -p SmTpR3l@Y + +EXPOSE 25 + +COPY init /sbin/ + +# Starting +ENTRYPOINT [ "/sbin/init" ] +CMD [ "start" ] diff --git a/init b/init new file mode 100755 index 0000000..53d0976 --- /dev/null +++ b/init @@ -0,0 +1,25 @@ +#!/bin/bash +set -e + +NAME="SMTP" + +function stop { + echo "Stopping ${NAME}" + kill $(cat /var/run/sendmail.pid|head -1) +} + +trap 'stop' SIGTERM + +if [ -z `hostname --domain` ]; then + echo "You must start this container with --hostname= specifying a domain name" + exit 1 +fi + +if [ "$1" == "start" ]; then + /usr/sbin/saslauthd -m /run/saslauthd -a pam + cd /etc/mail && rm -f *.db && make && m4 sendmail.mc > sendmail.cf && /usr/sbin/sendmail -q1h -bD & + + wait +else + exec $@ +fi