diff --git a/Dockerfile b/Dockerfile index af5ee1e..a0da40b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -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 @@ -10,9 +10,9 @@ ARG pg_version # "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 diff --git a/build_push.sh b/build_push.sh index 1abd758..f126fa6 100755 --- a/build_push.sh +++ b/build_push.sh @@ -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