Skip to content

Commit 3fde6e1

Browse files
authored
Merge pull request #5 from cisagov/improvement/upstream
Pull upstream. Modernize a bit.
2 parents e56a723 + a4867e4 commit 3fde6e1

File tree

9 files changed

+219
-79
lines changed

9 files changed

+219
-79
lines changed

.github/workflows/build.yml

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
name: build
3+
4+
on: [push]
5+
6+
env:
7+
IMAGE_NAME: cisagov/postfix
8+
PIP_CACHE_DIR: ~/.cache/pip
9+
PRE_COMMIT_CACHE_DIR: ~/.cache/pre-commit
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v1
16+
- uses: actions/setup-python@v1
17+
with:
18+
python-version: 3.7
19+
- name: Cache pip test requirements
20+
uses: actions/cache@v1
21+
with:
22+
path: ${{ env.PIP_CACHE_DIR }}
23+
key: "${{ runner.os }}-pip-test-\
24+
${{ hashFiles('**/requirements-test.txt') }}"
25+
restore-keys: |
26+
${{ runner.os }}-pip-test-
27+
${{ runner.os }}-pip-
28+
- name: Cache pre-commit hooks
29+
uses: actions/cache@v1
30+
with:
31+
path: ${{ env.PRE_COMMIT_CACHE_DIR }}
32+
key: "${{ runner.os }}-pre-commit-\
33+
${{ hashFiles('**/.pre-commit-config.yaml') }}"
34+
- name: Install dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install --upgrade -r requirements-test.txt
38+
- name: Run linters on all files
39+
run: pre-commit run --all-files
40+
build:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v1
44+
- name: Determine image version
45+
id: get_ver
46+
run: |
47+
echo "##[set-output name=version;]$(./bump_version.sh show)"
48+
- name: Build docker image
49+
run: |
50+
version=$(./bump_version.sh show)
51+
docker build \
52+
--tag "$IMAGE_NAME" \
53+
--build-arg GIT_COMMIT=$(git log -1 --format=%H) \
54+
--build-arg GIT_REMOTE=$(git remote get-url origin) \
55+
--build-arg VERSION=${{ steps.get_ver.outputs.version }} \
56+
.
57+
- name: Save docker image artifact
58+
run: |
59+
mkdir dist
60+
version=$(./bump_version.sh show)
61+
docker save $IMAGE_NAME:latest | gzip > dist/image.tar.gz
62+
- name: Upload artifacts
63+
uses: actions/upload-artifact@v1
64+
with:
65+
name: dist
66+
path: dist
67+
test:
68+
runs-on: ubuntu-latest
69+
needs: [build]
70+
steps:
71+
- uses: actions/checkout@v1
72+
- uses: actions/setup-python@v1
73+
with:
74+
python-version: 3.7
75+
- name: Cache pip test requirements
76+
uses: actions/cache@v1
77+
with:
78+
path: ${{ env.PIP_CACHE_DIR }}
79+
key: "${{ runner.os }}-pip-test-\
80+
${{ hashFiles('**/requirements-test.txt') }}"
81+
restore-keys: |
82+
${{ runner.os }}-pip-test-
83+
${{ runner.os }}-pip-
84+
- name: Install dependencies
85+
run: |
86+
python -m pip install --upgrade pip
87+
pip install --upgrade -r requirements-test.txt
88+
- name: Download docker image artifact
89+
uses: actions/download-artifact@v1
90+
with:
91+
name: dist
92+
- name: Load docker image
93+
run: docker load < dist/image.tar.gz
94+
- name: Run tests
95+
env:
96+
RELEASE_TAG: ${{ github.event.release.tag_name }}
97+
run: pytest

.github/workflows/release.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
name: release
3+
4+
on:
5+
release:
6+
types: [prereleased, released]
7+
8+
env:
9+
IMAGE_NAME: cisagov/postfix
10+
DOCKER_PW: ${{ secrets.DOCKER_PW }}
11+
DOCKER_USER: ${{ secrets.DOCKER_USER }}
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v1
18+
- uses: actions/setup-python@v1
19+
with:
20+
python-version: 3.7
21+
- name: Determine image version
22+
id: get_ver
23+
run: |
24+
echo "##[set-output name=version;]$(./bump_version.sh show)"
25+
- name: Build Docker image
26+
run: |
27+
docker build \
28+
--tag "$IMAGE_NAME" \
29+
--build-arg GIT_COMMIT=$(git log -1 --format=%H) \
30+
--build-arg GIT_REMOTE=$(git remote get-url origin) \
31+
--build-arg VERSION=${{ steps.get_ver.outputs.version }} \
32+
.
33+
- name: Tag Docker image
34+
run: |
35+
IFS='.' read -r -a version_array \
36+
<<< "${{ steps.get_ver.outputs.version }}"
37+
docker login --username "$DOCKER_USER" --password "$DOCKER_PW"
38+
docker tag "$IMAGE_NAME" "${IMAGE_NAME}:latest"
39+
docker tag "$IMAGE_NAME" \
40+
"${IMAGE_NAME}:${{ steps.get_ver.outputs.version }}"
41+
docker tag "$IMAGE_NAME" \
42+
"${IMAGE_NAME}:${version_array[0]}.${version_array[1]}"
43+
docker tag "$IMAGE_NAME" "${IMAGE_NAME}:${version_array[0]}"
44+
- name: Publish image to Docker Hub
45+
run: |
46+
IFS='.' read -r -a version_array \
47+
<<< "${{ steps.get_ver.outputs.version }}"
48+
docker push "${IMAGE_NAME}:latest"
49+
docker push "${IMAGE_NAME}:${{ steps.get_ver.outputs.version }}"
50+
docker push "${IMAGE_NAME}:${version_array[0]}.${version_array[1]}"
51+
docker push "${IMAGE_NAME}:${version_array[0]}"
52+
- name: Publish README.md to Docker Hub
53+
run: ./push_readme.sh

.pre-commit-config.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v2.2.3
4+
rev: v2.4.0
55
hooks:
66
- id: check-executables-have-shebangs
77
- id: check-json
@@ -24,32 +24,32 @@ repos:
2424
- id: requirements-txt-fixer
2525
- id: trailing-whitespace
2626
- repo: https://github.com/igorshubovych/markdownlint-cli
27-
rev: v0.17.0
27+
rev: v0.19.0
2828
hooks:
2929
- id: markdownlint
3030
args:
3131
- --config=.mdl_config.json
3232
- repo: https://github.com/adrienverge/yamllint
33-
rev: v1.16.0
33+
rev: v1.18.0
3434
hooks:
3535
- id: yamllint
3636
- repo: https://github.com/detailyang/pre-commit-shell
3737
rev: 1.0.5
3838
hooks:
3939
- id: shell-lint
4040
- repo: https://gitlab.com/pycqa/flake8
41-
rev: 3.7.7
41+
rev: 3.7.9
4242
hooks:
4343
- id: flake8
4444
additional_dependencies:
4545
- flake8-docstrings
4646
- repo: https://github.com/asottile/pyupgrade
47-
rev: v1.19.0
47+
rev: v1.25.1
4848
hooks:
4949
- id: pyupgrade
5050
# Run bandit on "tests" tree with a configuration
5151
- repo: https://github.com/PyCQA/bandit
52-
rev: 1.6.1
52+
rev: 1.6.2
5353
hooks:
5454
- id: bandit
5555
name: bandit (tests tree)
@@ -64,11 +64,11 @@ repos:
6464
name: bandit (everything else)
6565
exclude: tests
6666
- repo: https://github.com/python/black
67-
rev: 19.3b0
67+
rev: 19.10b0
6868
hooks:
6969
- id: black
7070
- repo: https://github.com/ansible/ansible-lint.git
71-
rev: v4.1.0a0
71+
rev: v4.1.1a3
7272
hooks:
7373
- id: ansible-lint
7474
- repo: https://github.com/antonbabenko/pre-commit-terraform.git

.travis.yml

-55
This file was deleted.

Dockerfile

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1+
ARG GIT_COMMIT=unspecified
2+
ARG GIT_REMOTE=unspecified
3+
ARG VERSION=unspecified
4+
15
FROM debian:buster-slim
2-
MAINTAINER Mark Feldhousen <[email protected]>
6+
7+
ARG GIT_COMMIT
8+
ARG GIT_REMOTE
9+
ARG VERSION
10+
11+
LABEL git_commit=${GIT_COMMIT}
12+
LABEL git_remote=${GIT_REMOTE}
13+
LABEL maintainer="[email protected]"
14+
LABEL vendor="Cyber and Infrastructure Security Agency"
15+
LABEL version=${VERSION}
316

417
RUN apt-get update && \
518
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
@@ -29,7 +42,7 @@ RUN mv /etc/default/opendkim /etc/default/opendkim.orig
2942
RUN mv /etc/default/opendmarc /etc/default/opendmarc.orig
3043

3144
COPY ./src/templates ./templates/
32-
COPY ./src/docker-entrypoint.sh .
45+
COPY ./src/docker-entrypoint.sh ./src/version.txt ./
3346

3447
VOLUME ["/var/log", "/var/spool/postfix"]
3548
EXPOSE 25/TCP 587/TCP 993/TCP

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# postfix-docker 📮🐳 #
22

3-
[![Build Status](https://travis-ci.com/cisagov/postfix-docker.svg?branch=develop)](https://travis-ci.com/cisagov/postfix-docker)
3+
[![GitHub Build Status](https://github.com/cisagov/postfix-docker/workflows/build/badge.svg)](https://github.com/cisagov/postfix-docker/actions)
4+
[![Total alerts](https://img.shields.io/lgtm/alerts/g/cisagov/postfix-docker.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cisagov/postfix-docker/alerts/)
5+
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/cisagov/postfix-docker.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cisagov/postfix-docker/context:python)
46

57
## Docker Image ##
68

7-
![MicroBadger Layers](https://img.shields.io/microbadger/layers/dhsncats/postfix.svg)
8-
![MicroBadger Size](https://img.shields.io/microbadger/image-size/dhsncats/postfix.svg)
9+
![MicroBadger Layers](https://img.shields.io/microbadger/layers/cisagov/postfix.svg)
10+
![MicroBadger Size](https://img.shields.io/microbadger/image-size/cisagov/postfix.svg)
911

1012
Creates a Docker container with an installation of the
1113
[postfix](http://postfix.org) MTA. Additionally it has an IMAP
@@ -16,11 +18,11 @@ of sent email. All email is BCC'd to the `mailarchive` account.
1618

1719
### Install ###
1820

19-
Pull `dhsncats/postfix` from the Docker repository:
21+
Pull `cisagov/postfix` from the Docker repository:
2022

21-
docker pull dhsncats/postfix
23+
docker pull cisagov/postfix
2224

23-
Or build `dhsncats/postfix` from source:
25+
Or build `cisagov/postfix` from source:
2426

2527
git clone https://github.com/cisagov/postfix-docker.git
2628
cd postfix-docker

docker-compose.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ secrets:
1313
services:
1414
postfix:
1515
build:
16+
# VERSION must be specified on the command line:
17+
# e.g., --build-arg VERSION=0.0.1
1618
context: .
1719
dockerfile: Dockerfile
18-
image: dhsncats/postfix
20+
image: cisagov/postfix
1921
init: true
2022
restart: always
2123
environment:

src/version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.2"
1+
__version__ = "0.0.3"

0 commit comments

Comments
 (0)