Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,9 @@ All the functionality for generating and storing the receptors and hexagons.

### Build_grid_receptors_to
All the functionality for generating and storing the receptors_to lookup tables.


## Image build
There are two scripts for building the Docker images.
* [`update.sh`](update.sh) - Creates the Dockerfile files for the specified Database-build versions.
* [`build_images.sh`](build_images.sh) - Builds all generated Dockerfile files.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1-SNAPSHOT
32 changes: 32 additions & 0 deletions build_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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}"

# If DOCKER_REGISTRY_URL is supplied we should prepend it to the image name
if [[ -z "${DOCKER_REGISTRY_URL:-}" ]]; then
IMAGE_NAME='aerius-database-modules'
else
IMAGE_NAME="${DOCKER_REGISTRY_URL}/database-modules"
fi

# Loop through all generated Docker directories
IMAGES_TO_PUSH=()
while read DIRECTORY; do
IMAGE_TAG=$(basename "${DIRECTORY}")
echo '# Building: '"${IMAGE_TAG}"
docker build --pull -t "${IMAGE_NAME}":"${IMAGE_TAG}" -f "${DIRECTORY}/Dockerfile" .

if [[ "${PUSH_IMAGES:-}" == 'true' ]]; then
IMAGES_TO_PUSH+=("${IMAGE_NAME}":"${IMAGE_TAG}")
fi
done < <(find docker/ -maxdepth 1 -type d -name '*-database-build_*')

# If there are images to push, do so
for IMAGE_TO_PUSH in "${IMAGES_TO_PUSH[@]}"; do
echo '# Pushing image: '"${IMAGE_TO_PUSH}"
docker push "${IMAGE_TO_PUSH}"
done
2 changes: 2 additions & 0 deletions docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore generated directories
*-database-build_*
5 changes: 5 additions & 0 deletions docker/Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# syntax = docker/dockerfile:1
FROM nexus-docker.aerius.nl/database-build:%%DATABASE_BUILD_VERSION%%

# Copy the database-modules source into the image
COPY source/modules/ /source/database-modules
30 changes: 30 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/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}"

# Database-Build versions
IMAGE_VERSIONS=(
"1.4.0-psql_15-pgis_3.4"
"1.4.0-psql_17-pgis_3.5"
)

# Read in current version of the script
BUILD_VERSION=$(<VERSION)

for DATABASE_BUILD_VERSION in "${IMAGE_VERSIONS[@]}"; do
echo "# Processing - Database-build: ${DATABASE_BUILD_VERSION}"
IMAGE_TAG="${BUILD_VERSION}-database-build_${DATABASE_BUILD_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/%%DATABASE_BUILD_VERSION%%/'"${DATABASE_BUILD_VERSION}"'/g;' \
docker/Dockerfile.template > "docker/${IMAGE_TAG}/Dockerfile"
done