forked from zalando/spilo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delivery.yaml
55 lines (55 loc) · 2.13 KB
/
delivery.yaml
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
version: "2017-09-20"
pipeline:
- id: build-spilo-cdp
env: &ENV
BASE_IMAGE: registry.opensource.zalan.do/library/ubuntu-18.04
IMAGE: registry-write.opensource.zalan.do/acid/spilo
PGVERSION: 14
type: script
commands:
- desc: Build spilo docker image
cmd: |
cd postgres-appliance
docker build --build-arg PGVERSION=$PGVERSION --build-arg BASE_IMAGE=$BASE_IMAGE -t spilo .
docker images
- desc: Test spilo docker image
cmd: |
sudo apt-get update
sudo apt-get install -y python3-pip
sudo pip3 install docker-compose==1.17.1
bash postgres-appliance/tests/test_spilo.sh
- desc: Tag and push spilo-cdp docker image
cmd: |
# push docker images only for commits to the master branch
if [ "x${CDP_SOURCE_BRANCH}" == "x" ] && [ "x${CDP_TARGET_BRANCH}" == "xmaster" ]; then
cd postgres-appliance
PATRONIVERSION=$(sed -n 's/^ENV PATRONIVERSION=\([1-9][0-9]*\.[0-9]*\).*$/\1/p' Dockerfile)
IMAGE="$IMAGE-cdp-$PGVERSION:$PATRONIVERSION-p$CDP_TARGET_BRANCH_COUNTER"
docker build --build-arg PGVERSION=$PGVERSION --build-arg BASE_IMAGE=$BASE_IMAGE -t $IMAGE .
docker images
docker push $IMAGE
fi
- id: tag-spilo
type: script
requires_human_approval: true
when:
event: push
branch: master
env:
<<: *ENV
commands:
- desc: Tag and push production spilo
cmd: |
sudo apt-get update
sudo apt-get install -y jq
PATRONIVERSION=$(sed -n 's/^ENV PATRONIVERSION=\([1-9][0-9]*\.[0-9]*\).*$/\1/p' postgres-appliance/Dockerfile)
CDP_IMAGE="$IMAGE-cdp-$PGVERSION:$PATRONIVERSION-p$CDP_TARGET_BRANCH_COUNTER"
docker pull $CDP_IMAGE
PIERONE_TAGS=$(curl -sL https://$(echo $IMAGE | sed 's|/|/v1/repositories/|')-$PGVERSION/tags)
COUNTER=$((git tag && echo "$PIERONE_TAGS" | jq -r 'keys | .[]') | sed -n "s/^$PATRONIVERSION-p//p" | sort -un | tail -n1)
TAG="$PATRONIVERSION-p$((COUNTER+1))"
PROD_IMAGE="$IMAGE-$PGVERSION:$TAG"
docker tag $CDP_IMAGE $PROD_IMAGE
docker images
docker push $PROD_IMAGE
git gh-tag -m $(echo $PROD_IMAGE | sed 's/-write//') $TAG