forked from aerius/database-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·33 lines (27 loc) · 1.12 KB
/
update.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
#!/bin/bash
set -Eeuo pipefail
# Change current directory to directory of script so it can be called from everywhere
SCRIPT_PATH=$(readlink -f "${0}")
SCRIPT_DIR=$(dirname "${SCRIPT_PATH}")
cd "${SCRIPT_DIR}"
# Key is the PostgreSQL version and values are the PostGIS versions images are available for that PostgreSQL version.
declare -A IMAGE_VERSIONS=(
[15]="3.4 3.3"
[14]="3.4 3.3"
)
# Read in current version of the script
BUILD_VERSION=$(<VERSION)
for POSTGRESQL_VERSION in "${!IMAGE_VERSIONS[@]}"; do
for POSTGIS_VERSION in ${IMAGE_VERSIONS[${POSTGRESQL_VERSION}]}; do
echo "# Processing - PostgreSQL: ${POSTGRESQL_VERSION} - PostGIS: ${POSTGIS_VERSION}"
IMAGE_TAG="${BUILD_VERSION}-psql_${POSTGRESQL_VERSION}-pgis_${POSTGIS_VERSION}"
# Create directory if it doesn't exist yet
if [[ ! -d "${IMAGE_TAG}" ]]; then
mkdir -p "docker/${IMAGE_TAG}"
fi
# Copy over files and process templates
sed -e 's/%%POSTGRESQL_VERSION%%/'"${POSTGRESQL_VERSION}"'/g;' \
-e 's/%%POSTGIS_VERSION%%/'"${POSTGIS_VERSION}"'/g;' \
docker/Dockerfile.template > "docker/${IMAGE_TAG}/Dockerfile"
done
done