Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Commit 806f2c1

Browse files
authored
Initial commit of repo (#1)
* Initial commit of repo * Update README, add CHANGELOG
1 parent ec3d08e commit 806f2c1

10 files changed

Lines changed: 263 additions & 1 deletion

File tree

.travis.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
stages:
3+
- Tests
4+
- SDLC Tasks
5+
- Build and Publish
6+
7+
jobs:
8+
include:
9+
- stage: Tests
10+
name: Shellcheck
11+
env:
12+
- SHELLCHECK_OPTS="-e SC1008 -e SC2154"
13+
language: bash
14+
script:
15+
- shellcheck $(find . -type f -name '*.sh')
16+
- name: Dockerfile linter
17+
language: minimal
18+
script:
19+
- docker run --rm -v $PWD:/root/ projectatomic/dockerfile-lint dockerfile_lint -f ./Dockerfile
20+
- stage: "SDLC Tasks"
21+
name: Tag & iteration update
22+
sudo: required
23+
language: bash
24+
script:
25+
- bash bin/travis-ci/check_tag.sh
26+
- stage: Build and Publish
27+
name: Docker image
28+
env:
29+
- secure: gtTzu+h5OXZJmsNTf1HilJqcjqiFgrcepTSh2vwzQ/WEv0ccRI2qz+aWxob9YH05/u23slHyJycQ1mxZzeZF2qWjuDZvQK2jMmZ+dDjW6i5KUsqeWJALVAZNVxJ49cMC91LvkHDFZEj2qEXw69ATrJ3dcs715fmYw3FunSgGvfwcmpR1XjznLEa8A2Zp2byVeMkf2YHp/GB0HqidAl7SvBmEuPpiDG/SuoX4oEoctgZDRNp473LskrdF6aj1JnVhUV3wb7iQCHnLyvW0ssaA73p2O4nw3OcMM+RMTFoPwJw2Oy5Rw8bjFy64gH0i/tiZw7v/Jmo9tVMh63TzPHwBvjg85gWgleYOwLbaJZ1SaT4QbDN4dgwlCPtfboZQBWtOuZzdeCahyRU/Fx1z0mZLWd5vpIXEQwFQw2UsFOA9CUfjAB0bzUGzw6Fiezgdtj21purLepNr1NwYYA8eOU3g19/2EWo8AqDQbPxkFGYKlq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NLppEf0Rduyx1O0pt9yJp8fZJfhZMNQ/ea37ef+cO5XWO5UwcpgB5IJqTf2/80iiwHDiJ8D6QOnmUlRRYAYFZEGFxt25YA53LR1FBjW7OWSKlFat4L2ewek8d0jfULcSY6ohviHDn+XWV2J2FAw82BD6BE5QFkGSJrt8VEtE0JeoZX+r466v653cM++53E/eRa5StU8SasUByn6wuaNk0J7zGLi87aSEXyDocz8dxA0FGnXiqHQM/FVxLuv1XCD53BWRmexstPqOB+UQpHmLka76khfT48W7Ay9pqgRQymYEqnzBu2WYleBjDxWIaohjiqpvD+JmEqLYMzwZe8w+/UIB0FXp6iSnw93TotT9P24oi2OfnDPlu8DcVlTzqh32i22iQWMEvd03dKaHyDyLt3I2hRJ8ojsMlSI2a07vgI0SsuMXnTBJ+Pb9/KzYVJGrpMfTZWsXdYeHFx6C4CcAFQAL4M/dWw6McNQWxi6Li4swK6LzUaDPU=
32+
language: minimal
33+
sudo: required
34+
services:
35+
- docker
36+
script:
37+
- bash bin/travis-ci/docker_upgrade.sh
38+
- bash bin/travis-ci/docker_build.sh
39+
- if [[ ${TRAVIS_BRANCH} = "master" ]]; then bash bin/travis-ci/docker_publish.sh; fi

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6+
7+
## [v0.1.1] - 2018-08-13
8+
### Added
9+
- Project `CHANGELOG.md`, `README.md`, and `LICENSE`
10+
- Initial commit of Docker, build, and configuration

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM ubuntu:bionic
2+
3+
LABEL name="postfix"
4+
LABEL version="latest"
5+
6+
# Disable frontend dialogs
7+
ENV DEBIAN_FRONTEND noninteractive
8+
9+
RUN apt-get update \
10+
&& apt-get install --yes \
11+
postfix \
12+
rsyslog \
13+
supervisor \
14+
&& apt-get --purge -y autoremove \
15+
&& apt-get --yes clean \
16+
&& rm -rf /etc/apt/sources.list.d/temp.list /var/lib/apt/lists/*
17+
18+
COPY ./supervisor.conf /etc/supervisor/conf.d/postfix.conf
19+
20+
COPY ./bin/postfix_init.sh /postfix_init.sh
21+
RUN chmod u+x /postfix_init.sh
22+
23+
CMD ["/usr/bin/python", "/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
# postfix-docker
1+
# postfix-docker
2+
3+
This repo deploys and configures `postfix` inside a Docker container.
4+
5+
## Configuration
6+
7+
See `./bin/postfix_init.sh` for configuration parameters that are available via environment variables.
8+
9+
## Features
10+
11+
* Supervisor to manaage `postfix`, `rsyslog`, and log output to `stdout`
12+
* Logging support is added with `rsyslog`

bin/postfix_init.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2018 SD Elements Inc.
4+
#
5+
# All Rights Reserved.
6+
#
7+
# NOTICE: All information contained herein is, and remains
8+
# the property of SD Elements Incorporated and its suppliers,
9+
# if any. The intellectual and technical concepts contained
10+
# herein are proprietary to SD Elements Incorporated
11+
# and its suppliers and may be covered by U.S., Canadian and other Patents,
12+
# patents in process, and are protected by trade secret or copyright law.
13+
# Dissemination of this information or reproduction of this material
14+
# is strictly forbidden unless prior written permission is obtained
15+
# from SD Elements Inc..
16+
# Version
17+
18+
set -eo pipefail
19+
20+
echo "Configuring postfix with any environment variables that are set"
21+
if [[ -n "${POSTFIX_MYNETWORKS}" ]]; then
22+
echo "Setting custom 'mynetworks' to '${POSTFIX_MYNETWORKS}'"
23+
postconf mynetworks="${POSTFIX_MYNETWORKS}"
24+
else
25+
echo "Revert 'mynetworks' to default"
26+
postconf mynetworks="127.0.0.1/32 172.0.0.0/8"
27+
fi
28+
29+
if [[ -n "${POSTFIX_RELAYHOST}" ]]; then
30+
echo "Setting custom 'relayhost' to '${POSTFIX_RELAYHOST}'"
31+
postconf relayhost="${POSTFIX_RELAYHOST}"
32+
else
33+
echo "Revert 'relayhost' to default (unset)"
34+
postconf -# relayhost
35+
fi
36+
37+
echo "Disable chroot for the smtp service"
38+
postconf -F smtp/inet/chroot=n
39+
postconf -F smtp/unix/chroot=n
40+
41+
echo "Starting postfix in the foreground"
42+
postfix start-fg

bin/travis-ci/check_tag.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2018 SD Elements Inc.
4+
#
5+
# All Rights Reserved.
6+
#
7+
# NOTICE: All information contained herein is, and remains
8+
# the property of SD Elements Incorporated and its suppliers,
9+
# if any. The intellectual and technical concepts contained
10+
# herein are proprietary to SD Elements Incorporated
11+
# and its suppliers and may be covered by U.S., Canadian and other Patents,
12+
# patents in process, and are protected by trade secret or copyright law.
13+
# Dissemination of this information or reproduction of this material
14+
# is strictly forbidden unless prior written permission is obtained
15+
# from SD Elements Inc..
16+
# Version
17+
18+
set -eo pipefail
19+
20+
# echo "Installing shtdlib"
21+
shtdlib_local_path="/usr/local/bin/shtdlib.sh"
22+
sudo curl -s -L -o "${shtdlib_local_path}" https://github.com/sdelements/shtdlib/raw/master/shtdlib.sh
23+
sudo chmod 775 "${shtdlib_local_path}"
24+
# shellcheck disable=SC1091,SC1090
25+
source "${shtdlib_local_path}"
26+
color_echo green "shtdlib.sh installed successfully"
27+
28+
# Get the latest tag from GitHub
29+
latest_tag="$(git fetch -t && git tag -l | sort --version-sort | tail -n1)"
30+
color_echo green "Latest Git tag: '${latest_tag}'"
31+
32+
# Get the latest tag from the CHANGELOG
33+
changelog_ver="$(grep -oP '\[v\d\.\d\.\d\]' CHANGELOG.md | tr -d '[]' | sort -nr | head -n1)"
34+
color_echo green "CHANGELOG version: '${changelog_ver}'"
35+
36+
# Validate version strings
37+
version_pattern='^v\d\.\d\.\d$'
38+
echo "${latest_tag}" | grep -qP ${version_pattern} || ( color_echo red "Invalid tag from repo: '${latest_tag}'" && exit 1 )
39+
echo "${changelog_ver}" | grep -qP ${version_pattern} || ( color_echo red "Invalid tag from CHANGELOG: '${changelog_ver}'" && exit 1 )
40+
41+
# Ensure tags in CHANGELOG and iteration are greater than highest repo tag
42+
if [ "${latest_tag}" = "${changelog_ver}" ] \
43+
|| ! compare_versions "${latest_tag}" "${changelog_ver}"; then
44+
color_echo red "Error: Version in CHANGELOG.md not updated"
45+
exit 1
46+
else
47+
color_echo green "Version bumps PASS!"
48+
fi

bin/travis-ci/docker_build.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2018 SD Elements Inc.
4+
#
5+
# All Rights Reserved.
6+
#
7+
# NOTICE: All information contained herein is, and remains
8+
# the property of SD Elements Incorporated and its suppliers,
9+
# if any. The intellectual and technical concepts contained
10+
# herein are proprietary to SD Elements Incorporated
11+
# and its suppliers and may be covered by U.S., Canadian and other Patents,
12+
# patents in process, and are protected by trade secret or copyright law.
13+
# Dissemination of this information or reproduction of this material
14+
# is strictly forbidden unless prior written permission is obtained
15+
# from SD Elements Inc..
16+
# Version
17+
18+
set -eo pipefail
19+
20+
# Build image
21+
docker build --no-cache --tag "${DOCKER_REGISTRY_URL}/postfix" .
22+
docker images

bin/travis-ci/docker_publish.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2018 SD Elements Inc.
4+
#
5+
# All Rights Reserved.
6+
#
7+
# NOTICE: All information contained herein is, and remains
8+
# the property of SD Elements Incorporated and its suppliers,
9+
# if any. The intellectual and technical concepts contained
10+
# herein are proprietary to SD Elements Incorporated
11+
# and its suppliers and may be covered by U.S., Canadian and other Patents,
12+
# patents in process, and are protected by trade secret or copyright law.
13+
# Dissemination of this information or reproduction of this material
14+
# is strictly forbidden unless prior written permission is obtained
15+
# from SD Elements Inc..
16+
# Version
17+
18+
set -eo pipefail
19+
20+
# Log into our Docker registry
21+
echo "${DOCKER_REGISTRY_PASSWORD}" | docker login -u "${DOCKER_REGISTRY_USER}" --password-stdin "${DOCKER_REGISTRY_URL}"
22+
23+
# Push image
24+
docker push "${DOCKER_REGISTRY_URL}/postfix:latest"

bin/travis-ci/docker_upgrade.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2018 SD Elements Inc.
4+
#
5+
# All Rights Reserved.
6+
#
7+
# NOTICE: All information contained herein is, and remains
8+
# the property of SD Elements Incorporated and its suppliers,
9+
# if any. The intellectual and technical concepts contained
10+
# herein are proprietary to SD Elements Incorporated
11+
# and its suppliers and may be covered by U.S., Canadian and other Patents,
12+
# patents in process, and are protected by trade secret or copyright law.
13+
# Dissemination of this information or reproduction of this material
14+
# is strictly forbidden unless prior written permission is obtained
15+
# from SD Elements Inc..
16+
# Version
17+
18+
set -eo pipefail
19+
20+
# Update docker
21+
sudo apt-get update
22+
sudo apt-get --yes install docker-ce
23+
24+
# Update docker-compose
25+
sudo rm /usr/local/bin/docker-compose
26+
sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
27+
sudo chmod +x /usr/local/bin/docker-compose
28+
29+
# Verify
30+
docker version && docker-compose --version

supervisor.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:postfix]
5+
command=/postfix_init.sh
6+
7+
[program:rsyslog]
8+
command=/usr/sbin/rsyslogd -n
9+
10+
[program:readlog]
11+
command=/usr/bin/tail -F /var/log/mail.log
12+
stdout_logfile=/dev/fd/1
13+
stdout_logfile_maxbytes=0

0 commit comments

Comments
 (0)