Provide version information through labels (#1256)

* Provide version information through labels

Can be retrieved by calling e.g. `docker inspect -f {{.Config.Labels}} tvial/docker-mailserver:testing`

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* add build hook so that Docker Hub can work with the build args

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* remove obsolete build-no-cache

build args invalidate build cache already

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* adapt travis file

Signed-off-by: Felix Bartels <felix@host-consultants.de>

* shellcheck

Signed-off-by: Felix Bartels <felix@host-consultants.de>
This commit is contained in:
Felix Bartels 2019-10-23 11:22:23 +02:00 committed by GitHub
parent 1029777ffa
commit 7ff9764285
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 11 deletions

View file

@ -13,7 +13,7 @@ before_install:
- sudo chmod +rx /usr/local/bin/hadolint - sudo chmod +rx /usr/local/bin/hadolint
install: install:
- make lint - make lint
- travis_retry travis_wait make build-no-cache - travis_retry travis_wait make build
script: script:
- make generate-accounts run generate-accounts-after-run fixtures tests - make generate-accounts run generate-accounts-after-run fixtures tests
after_script: after_script:

View file

@ -1,5 +1,16 @@
FROM debian:stretch-slim FROM debian:stretch-slim
LABEL maintainer="Thomas VIAL"
ARG VCS_REF
ARG VCS_VERSION
LABEL maintainer="Thomas VIAL" \
org.label-schema.name="docker-mailserver" \
org.label-schema.description="A fullstack but simple mailserver (smtp, imap, antispam, antivirus, ssl...)" \
org.label-schema.url="https://github.com/tomav/docker-mailserver" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/tomav/docker-mailserver" \
org.label-schema.version=$VCS_VERSION \
org.label-schema.schema-version="1.0"
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
ENV VIRUSMAILS_DELETE_DELAY=7 ENV VIRUSMAILS_DELETE_DELAY=7

View file

@ -1,15 +1,15 @@
NAME = tvial/docker-mailserver:testing NAME = tvial/docker-mailserver:testing
VCS_REF := $(shell git rev-parse --short HEAD)
VCS_VERSION := $(shell git describe)
all: build-no-cache backup generate-accounts run generate-accounts-after-run fixtures tests clean all: build backup generate-accounts run generate-accounts-after-run fixtures tests clean
all-fast: build backup generate-accounts run generate-accounts-after-run fixtures tests clean
no-build: backup generate-accounts run generate-accounts-after-run fixtures tests clean no-build: backup generate-accounts run generate-accounts-after-run fixtures tests clean
build-no-cache:
export DOCKER_MAIL_DOCKER_BUILD_NO_CACHE=--no-cache
docker build --no-cache -t $(NAME) .
build: build:
docker build -t $(NAME) . docker build \
--build-arg VCS_REF=$(VCS_REF) \
--build-arg VCS_VERSION=$(VCS_VERSION) \
-t $(NAME) .
backup: backup:
# if backup directories exist, clean hasn't been called, therefore we shouldn't overwrite it. It still contains the original content. # if backup directories exist, clean hasn't been called, therefore we shouldn't overwrite it. It still contains the original content.

8
hooks/build Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh
VCS_REF=$(git rev-parse --short HEAD)
VCS_VERSION=$(git describe)
docker build \
--build-arg VCS_REF="$VCS_REF" \
--build-arg VCS_VERSION="$VCS_VERSION" \
-f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" .

View file

@ -10,7 +10,7 @@ function teardown() {
function setup_file() { function setup_file() {
pushd test/docker-openldap/ pushd test/docker-openldap/
docker build -f Dockerfile -t ldap $DOCKER_MAIL_DOCKER_BUILD_NO_CACHE . docker build -f Dockerfile -t ldap --no-cache .
popd popd
docker run -d --name ldap_for_mail \ docker run -d --name ldap_for_mail \