Skip to content

Commit

Permalink
Added a custom dockerfile for postgres to install and activate postgis
Browse files Browse the repository at this point in the history
  • Loading branch information
antoineludeau committed Sep 28, 2023
1 parent 38dbfa5 commit c8e7fb2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ services:
volumes:
- db-mongo:/data/db
db-postgres:
image: postgres:15-alpine
build:
dockerfile: docker-resources/postgres/Dockerfile.dev
ports:
- "${POSTGRES_PORT:-5432}:5432"
environment:
Expand Down
8 changes: 8 additions & 0 deletions docker-resources/postgres/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Use the official PostgreSQL image as the base image
FROM postgres:15

# Install PostGIS extension
RUN apt-get update && apt-get install -y postgresql-15-postgis-3

# Copy a script to activate PostGIS
COPY docker-resources/postgres/init-postgis.sh /docker-entrypoint-initdb.d
5 changes: 5 additions & 0 deletions docker-resources/postgres/init-postgis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e

echo "Activating PostGIS extension..."
psql -U $POSTGRES_USER -d $POSTGRES_DB -c "CREATE EXTENSION postgis;"

0 comments on commit c8e7fb2

Please sign in to comment.