summaryrefslogtreecommitdiff
path: root/salt/openbook/ci/files/build.sh
blob: abcba51fd5ee8bbf7422c88af9d713bd4c887637 (plain)
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
#!/bin/bash

artifact="${1}"

for i in $(docker images | grep -v CREATED | awk '{print $3}'); do
    docker rmi --force $i
done
docker container prune -f

pushd {{ pillar["ci"]["build_dir"] }} 2>/dev/null

echo "Login to docker registry"
docker login --username {{ pillar["registry"]["username"] }} --password {{ pillar["registry"]["password"] }} {{ pillar["registry"]["url"] }}

# for i in $(curl -u '{{ pillar["registry"]["username"] }}:{{ pillar["registry"]["password"] }}' https://{{ pillar["registry"]["url"] }}/v2/_catalog | jq '.repositories' | fgrep 'openbook' | awk -F\" '{print $2}'); do
#     # get reference digest
#     digest=$(curl -u '{{ pillar["registry"]["username"] }}:{{ pillar["registry"]["password"] }}' -H "Accept: application/vnd.docker.distribution.manifest.v2+json" https://{{ pillar["registry"]["url"] }}/v2/${i}/manifests/latest | jq '.config | .digest' | awk -F\" '{print $2}')
#     curl -u '{{ pillar["registry"]["username"] }}:{{ pillar["registry"]["password"] }}' -X DELETE https://{{ pillar["registry"]["url"] }}/v2/${i}/manifests/${digest}
# done

if [ "${artifact}" == "database" ]; then
    {{ pillar["database"]["build_dir"] }}/build.sh
elif [ "${artifact}" == "admin-api-server" ]; then
    {{ pillar["admin_api_server"]["build_dir"] }}/build.sh
elif [ "${artifact}" == "customer-api-server" ]; then
    {{ pillar["customer_api_server"]["build_dir"] }}/build.sh
elif [ "${artifact}" == "admin-web-ui" ]; then
    {{ pillar["admin_web_ui"]["build_dir"] }}/build.sh
elif [ "${artifact}" == "customer-web-ui" ]; then
    {{ pillar["customer_web_ui"]["build_dir"] }}/build.sh
elif [ "${artifact}" == "job-scheduler-server" ]; then
    {{ pillar["job_scheduler_server"]["build_dir"] }}/build.sh
elif [ "${artifact}" == "workflow-server" ]; then
    {{ pillar["workflow_server"]["build_dir"] }}/build.sh
else
    {{ pillar["database"]["build_dir"] }}/build.sh
    {{ pillar["admin_api_server"]["build_dir"] }}/build.sh
    {{ pillar["customer_api_server"]["build_dir"] }}/build.sh
    {{ pillar["admin_web_ui"]["build_dir"] }}/build.sh
    {{ pillar["customer_web_ui"]["build_dir"] }}/build.sh
    {{ pillar["job_scheduler_server"]["build_dir"] }}/build.sh
    {{ pillar["workflow_server"]["build_dir"] }}/build.sh
fi

popd 2>/dev/null
exit 0