forked from sqitchers/docker-sqitch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·48 lines (41 loc) · 1.68 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -e
NAME=sqitch
VERSION=1.0.0
DIR=${DIR:=.}
REGISTRY=${REGISTRY:="$NAME"}
GIT_BRANCH=${GIT_BRANCH:-${TRAVIS_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}}
# For main Sqitch build, the main tag is "latest" and there
# is no sub-package.
PKG=""
TAG="latest"
if [ "$DIR" != "." ]; then
# For other builds, we need to append a sub-package name and use the
# diretory name as the main tag.
cd $DIR
PKG="-$DIR"
TAG="$DIR"
fi
# Only include the latest or directory tag when building master.
tagopt=()
if [[ "$GIT_BRANCH" =~ (^|/)master$ ]]; then
tagopt+=(--tag "${REGISTRY}/${NAME}:${TAG}")
fi
# Always include the version tag.
tagopt+=(--tag "${REGISTRY}/${NAME}:${VERSION}${PKG}")
docker build --pull \
--label org.opencontainers.image.created=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label org.opencontainers.image.authors='Sqitch Hackers <sqitch-hackers@googlegroups.com>' \
--label org.opencontainers.image.url="https://hub.docker.com/r/sqitch/sqitch/" \
--label org.opencontainers.image.documentation="https://github.com/sqitchers/docker-sqitch#readme" \
--label org.opencontainers.image.source="https://github.com/sqitchers/docker-sqitch" \
--label org.opencontainers.image.version="$VERSION" \
--label org.opencontainers.image.revision="$(git rev-parse --abbrev-ref HEAD)" \
--label org.opencontainers.image.vendor="The Sqitch Community" \
--label org.opencontainers.image.licenses="MIT" \
--label org.opencontainers.image.ref.name="sqitch${PKG}-${VERSION}" \
--label org.opencontainers.image.title="Sqitch" \
--label org.opencontainers.image.description="Sane database change management" \
"${tagopt[@]}" \
--build-arg "VERSION=${VERSION}" \
"$@" .