Skip to content

Commit

Permalink
improve the build script
Browse files Browse the repository at this point in the history
  • Loading branch information
abbotto committed Sep 30, 2019
1 parent c739e00 commit f85b937
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
ARG pg_alpine_branch
FROM alpine:${pg_alpine_branch}
ARG alpine_version
FROM alpine:${alpine_version}

ARG pg_alpine_branch
ARG pg_version
ARG alpine_version
ARG pg_package_version

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

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

Expand Down
36 changes: 25 additions & 11 deletions build_push.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
#!/usr/bin/env sh

alpine_version='3.8'
legacy_image=false
pg_major_version='10'
pg_package_version='10.10'

builds=\
"10.10_10.10-r0_3.8",\
"10_10.10-r0_3.8",\
"latest_10.10-r0_3.8"
"${pg_package_version}_${pg_package_version}-r0_${alpine_version}",\
"${pg_major_version}_${pg_package_version}-r0_${alpine_version}"

if [ "${legacy_image}" = 'false' ]; then
builds="${builds}","latest_${pg_package_version}-r0_${alpine_version}"
fi

echo $builds | tr ',' '\n' | while read build; do
alpine_version=$(echo "${build}" | cut -d '_' -f 3)
pg_restore_from_s3_tag=$(echo "${build}" | cut -d '_' -f 1 )
pg_package_version=$(echo "${build}" | cut -d '_' -f 2)

for build in $(echo $builds | tr ',' '\n'); do
tag=$(echo "${build}" | cut -d '_' -f 1 )
pg_version=$(echo "${build}" | cut -d '_' -f 2)
pg_alpine_branch=$(echo "${build}" | cut -d '_' -f 3)
echo ""
echo "--------------------------------"
echo "POSTGRES-RESTORE-FROM-S3 TAG: ${pg_restore_from_s3_tag}"
echo "POSTGRES PACKAGE VERSION: ${pg_package_version}"
echo "--------------------------------"

echo docker build --tag bluedrop360/postgres-restore-from-s3:"${tag}" --build-arg pg_version="${pg_version}" --build-arg pg_alpine_branch="${pg_alpine_branch}" .
eval docker build --tag bluedrop360/postgres-restore-from-s3:"${tag}" --build-arg pg_version="${pg_version}" --build-arg pg_alpine_branch="${pg_alpine_branch}" .
echo docker push bluedrop360/postgres-restore-from-s3:"${tag}"
eval docker push bluedrop360/postgres-restore-from-s3:"${tag}"
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}" .
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
echo docker push bluedrop360/postgres-restore-from-s3:$pg_restore_from_s3_tag
eval docker push bluedrop360/postgres-restore-from-s3:$pg_restore_from_s3_tag || exit 1
done

0 comments on commit f85b937

Please sign in to comment.