-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·47 lines (40 loc) · 1.36 KB
/
build.sh
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
#!/bin/sh
PG_VERS=(12.19 13.15 14.12 15.7 16.3)
DEBIAN=bookworm
for pg_ver in "${PG_VERS[@]}";
do
echo ---BUILD ${pg_ver}---
if git rev-parse $pg_ver >/dev/null 2>&1
then
continue
fi
major=$(echo ${pg_ver} | sed -E "s/([0-9\.]+)\.[0-9]+$/\1/")
if [[ "$OSTYPE" == "darwin"* ]]; then
# MacOS
sed -i '' -E 's/(FROM postgres):[0-9\.]+.*/\1:'"${pg_ver}-${DEBIAN}"'/' Dockerfile
sed -i '' -E 's/(postgresql-)[0-9\.]+(-hll)/\1'"$major"'\2/' Dockerfile
sed -i '' -E "s/\w+-pgdg main/${DEBIAN}-pgdg main/" Dockerfile
else
sed -i -E 's/(FROM postgres):[0-9\.]+.*/\1:'"${pg_ver}-${DEBIAN}"'/' Dockerfile
sed -i -E 's/(postgresql-)[0-9\.]+(-hll)/\1'"$major"'\2/' Dockerfile
sed -i -E "s/\w+-pgdg main/${DEBIAN}-pgdg main/" Dockerfile
fi
name="jasei/postgres-hll:${pg_ver}"
docker build -t $name .
test_cmd="docker run --rm -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -d jasei/postgres-hll:${pg_ver}"
instance=$($test_cmd)
echo "TESTING of $instance ($test_cmd)"
sleep 5;
if docker logs ${instance} | grep "CREATE EXTENSION"
then
git add Dockerfile
git commit -m "${pg_ver}"
git tag ${pg_ver}
docker push $name
git push origin "${pg_ver}"
else
echo Something wrong!
exit 1
fi
docker stop ${instance}
done