Skip to content

Commit 726d14a

Browse files
committed
improve the build script
1 parent c739e00 commit 726d14a

2 files changed

Lines changed: 32 additions & 17 deletions

File tree

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
ARG pg_alpine_branch
2-
FROM alpine:${pg_alpine_branch}
1+
ARG alpine_version
2+
FROM alpine:${alpine_version}
33

4-
ARG pg_alpine_branch
5-
ARG pg_version
4+
ARG alpine_version
5+
ARG pg_package_version
66

77
#--------------------------------------------------------------------------------
88
# Install dependencies
99
#--------------------------------------------------------------------------------
1010
# "postgresql" is required for "pg_restore"
1111
# "py-pip" is required for "aws-cli"
1212
#--------------------------------------------------------------------------------
13-
RUN echo "http://dl-cdn.alpinelinux.org/alpine/v${pg_alpine_branch}/main" >> /etc/apk/repositories
13+
RUN echo "http://dl-cdn.alpinelinux.org/alpine/v${alpine_version}/main" >> /etc/apk/repositories
1414

15-
RUN apk --no-cache --update add dumb-init postgresql=${pg_version} py-pip && \
15+
RUN apk --no-cache --update add dumb-init postgresql=${pg_package_version} py-pip && \
1616
pip install awscli && \
1717
apk --purge -v del py-pip
1818

build_push.sh

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
#!/usr/bin/env sh
22

3+
# Versions
4+
alpine_version='3.8'
5+
legacy_image=false
6+
pg_major_version='10'
7+
pg_package_version='10.10'
8+
39
builds=\
4-
"10.10_10.10-r0_3.8",\
5-
"10_10.10-r0_3.8",\
6-
"latest_10.10-r0_3.8"
10+
"${pg_package_version}_${pg_package_version}-r0_${alpine_version}",\
11+
"${pg_major_version}_${pg_package_version}-r0_${alpine_version}"
12+
13+
if [ "${legacy_image}" = 'false' ]; then
14+
builds="${builds}","latest_${pg_package_version}-r0_${alpine_version}"
15+
fi
16+
17+
echo $builds | tr ',' '\n' | while read build; do
18+
alpine_version=$(echo "${build}" | cut -d '_' -f 3)
19+
pg_restore_from_s3_tag=$(echo "${build}" | cut -d '_' -f 1 )
20+
pg_package_version=$(echo "${build}" | cut -d '_' -f 2)
721

8-
for build in $(echo $builds | tr ',' '\n'); do
9-
tag=$(echo "${build}" | cut -d '_' -f 1 )
10-
pg_version=$(echo "${build}" | cut -d '_' -f 2)
11-
pg_alpine_branch=$(echo "${build}" | cut -d '_' -f 3)
22+
echo ""
23+
echo "--------------------------------"
24+
echo "POSTGRES-RESTORE-FROM-S3 TAG: ${pg_restore_from_s3_tag}"
25+
echo "POSTGRES PACKAGE VERSION: ${pg_package_version}"
26+
echo "--------------------------------"
1227

13-
echo docker build --tag bluedrop360/postgres-restore-from-s3:"${tag}" --build-arg pg_version="${pg_version}" --build-arg pg_alpine_branch="${pg_alpine_branch}" .
14-
eval docker build --tag bluedrop360/postgres-restore-from-s3:"${tag}" --build-arg pg_version="${pg_version}" --build-arg pg_alpine_branch="${pg_alpine_branch}" .
15-
echo docker push bluedrop360/postgres-restore-from-s3:"${tag}"
16-
eval docker push bluedrop360/postgres-restore-from-s3:"${tag}"
28+
echo docker build --tag bluedrop360/postgres-restore-from-s3:$pg_restore_from_s3_tag --build-arg pg_package_version=$pg_package_version --build-arg alpine_version="${alpine_version}" .
29+
eval docker build --tag bluedrop360/postgres-restore-from-s3:$pg_restore_from_s3_tag --build-arg pg_package_version=$pg_package_version --build-arg alpine_version="${alpine_version}" . || exit 1
30+
echo docker push bluedrop360/postgres-restore-from-s3:$pg_restore_from_s3_tag
31+
eval docker push bluedrop360/postgres-restore-from-s3:$pg_restore_from_s3_tag || exit 1
1732
done

0 commit comments

Comments
 (0)