forked from zalando/spilo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delivery.yaml
94 lines (92 loc) · 3.32 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
version: "2017-09-20"
allow_concurrent_steps: true
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
vm_config:
type: linux
commands:
- desc: Build spilo docker image
cmd: |
chmod -R o-w postgres-appliance
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
depends_on: [build-spilo-cdp]
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
- id: build-spilo-cdp-arm64
env:
<<: *ENV
ARCH: arm64
type: script
requires_human_approval: true
timeout: 10h
vm_config:
type: linux
size: large
priority: 3
commands:
- desc: Setup environment
cmd: |
docker run --privileged --rm tonistiigi/binfmt --install "$ARCH"
- desc: Build spilo-cdp-arm64 docker image
cmd: |
chmod -R o-w postgres-appliance
cd postgres-appliance
docker buildx build --platform "linux/$ARCH" --build-arg PGVERSION=$PGVERSION -t spilo .
docker images
- desc: Tag and push spilo-cdp-arm64 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-$ARCH-$PGVERSION:$PATRONIVERSION-p$CDP_TARGET_BRANCH_COUNTER"
docker tag spilo $IMAGE
docker images
docker push $IMAGE
fi