add source code and readme
This commit is contained in:
35
build/postgresql-postgis/Dockerfile
Normal file
35
build/postgresql-postgis/Dockerfile
Normal file
@@ -0,0 +1,35 @@
|
||||
# CloudNativePG-compatible PostGIS image
|
||||
# Uses imresamu/postgis as base which has ARM64 support
|
||||
FROM imresamu/postgis:16-3.4
|
||||
|
||||
# Get additional tools from CloudNativePG image
|
||||
FROM ghcr.io/cloudnative-pg/postgresql:16.6 as cnpg-tools
|
||||
|
||||
# Final stage: PostGIS with CloudNativePG tools
|
||||
FROM imresamu/postgis:16-3.4
|
||||
|
||||
USER root
|
||||
|
||||
# Fix user ID compatibility with CloudNativePG (user ID 26)
|
||||
# CloudNativePG expects postgres user to have ID 26, but imresamu/postgis uses 999
|
||||
# The tape group (ID 26) already exists, so we'll change postgres user to use it
|
||||
RUN usermod -u 26 -g 26 postgres && \
|
||||
delgroup postgres && \
|
||||
chown -R postgres:tape /var/lib/postgresql && \
|
||||
chown -R postgres:tape /var/run/postgresql
|
||||
|
||||
# Copy barman and other tools from CloudNativePG image
|
||||
COPY --from=cnpg-tools /usr/local/bin/barman* /usr/local/bin/
|
||||
|
||||
# Install any additional packages that CloudNativePG might need
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
jq \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Switch back to postgres user (now with correct ID 26)
|
||||
USER postgres
|
||||
|
||||
# Keep the standard PostgreSQL entrypoint
|
||||
# CloudNativePG operator will manage the container lifecycle
|
||||
41
build/postgresql-postgis/build.sh
Executable file
41
build/postgresql-postgis/build.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Build script for ARM64 PostGIS image compatible with CloudNativePG
|
||||
|
||||
REGISTRY="<YOUR_REGISTRY_URL>/library"
|
||||
IMAGE_NAME="cnpg-postgis"
|
||||
TAG="16.6-3.4-v2"
|
||||
FULL_IMAGE="${REGISTRY}/${IMAGE_NAME}:${TAG}"
|
||||
LOCAL_IMAGE="${IMAGE_NAME}:${TAG}"
|
||||
|
||||
echo "Building ARM64 PostGIS image: ${FULL_IMAGE}"
|
||||
|
||||
# Build the image
|
||||
docker build \
|
||||
--platform linux/arm64 \
|
||||
-t "${FULL_IMAGE}" \
|
||||
.
|
||||
|
||||
echo "Image built successfully: ${FULL_IMAGE}"
|
||||
|
||||
# Test the image by running a container and checking PostGIS availability
|
||||
echo "Testing PostGIS installation..."
|
||||
docker run --rm --platform linux/arm64 "${FULL_IMAGE}" \
|
||||
postgres --version
|
||||
|
||||
echo "Tagging image for local testing..."
|
||||
docker tag "${FULL_IMAGE}" "${LOCAL_IMAGE}"
|
||||
|
||||
echo "Image built and tagged as:"
|
||||
echo " Harbor registry: ${FULL_IMAGE}"
|
||||
echo " Local testing: ${LOCAL_IMAGE}"
|
||||
|
||||
echo ""
|
||||
echo "To push to Harbor registry (when ready for deployment):"
|
||||
echo " docker push ${FULL_IMAGE}"
|
||||
|
||||
echo ""
|
||||
echo "Build completed successfully!"
|
||||
echo "Local testing image: ${LOCAL_IMAGE}"
|
||||
echo "Harbor registry image: ${FULL_IMAGE}"
|
||||
Reference in New Issue
Block a user