Skip to content

Instantly share code, notes, and snippets.

@eliyas5044
Created November 10, 2025 12:58
Show Gist options
  • Select an option

  • Save eliyas5044/628f7c6e5420395c87f3e1af9e03388f to your computer and use it in GitHub Desktop.

Select an option

Save eliyas5044/628f7c6e5420395c87f3e1af9e03388f to your computer and use it in GitHub Desktop.
# syntax=docker.io/docker/dockerfile:1.7
# PostgreSQL with PostGIS for ARM64
# Based on official postgres image with PostGIS extension
ARG POSTGRES_VERSION=16
FROM postgres:${POSTGRES_VERSION}-bookworm
# Re-declare build argument for use in labels
ARG POSTGRES_VERSION=16
# Install PostGIS and dependencies, create init script, and set permissions
RUN apt-get update && apt-get install -y --no-install-recommends \
postgresql-${PG_MAJOR}-postgis-3 \
postgresql-${PG_MAJOR}-postgis-3-scripts \
postgis \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /docker-entrypoint-initdb.d
# Create initialization script to enable PostGIS extension
COPY <<'EOF' /docker-entrypoint-initdb.d/10_postgis.sh
#!/bin/bash
set -e
# Enable PostGIS extension for the default database
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS postgis_topology;
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;
EOSQL
EOF
RUN chmod +x /docker-entrypoint-initdb.d/10_postgis.sh
# Labels for better organization
LABEL maintainer="devxhub"
LABEL description="PostgreSQL ${POSTGRES_VERSION} with PostGIS 3.x for ARM64"
LABEL org.opencontainers.image.source="https://github.com/devxhub"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment