-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrun
executable file
·59 lines (50 loc) · 1.21 KB
/
run
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
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
set -eu -o pipefail
IMAGE_NAME=postfix
PLATFORMS="linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7"
build () {
docker build -t "${IMAGE_NAME}:tmp" -f Dockerfile .
}
_test() {
build
_down
bundle install --path vendor/bundle
bundle exec rspec --format documentation
}
_down () {
docker-compose down --remove-orphans
}
usage() {
echo "./run test|build|push"
}
find_release(){
TAG="$(git tag | sort -n | tail -n 1)"
export TAG
}
release() {
export DOCKER_CLI_EXPERIMENTAL=enabled
find_release
git checkout "${TAG}"
docker buildx use testbuilder || docker buildx create --name testbuilder
docker buildx inspect --bootstrap
docker buildx build \
--platform "${PLATFORMS}" \
-t "timjdfletcher/${IMAGE_NAME}:${TAG}" --push .
}
push() {
_test
TAG=$(git rev-parse --short HEAD)
docker tag "${IMAGE_NAME}:tmp" "timjdfletcher/${IMAGE_NAME}:${TAG}"
docker tag "${IMAGE_NAME}:tmp" "timjdfletcher/${IMAGE_NAME}:latest"
docker push "timjdfletcher/${IMAGE_NAME}:${TAG}"
docker push "timjdfletcher/${IMAGE_NAME}:latest"
}
CMD=${1:-}
shift || true
case ${CMD} in
build) build ;;
test) _test ;;
push) push ;;
release) release ;;
*) usage ;;
esac