Skip to content

Commit

Permalink
add pg_featureserv
Browse files Browse the repository at this point in the history
  • Loading branch information
adamscarberry committed Nov 21, 2024
1 parent 8cd44d3 commit 9d72451
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
13 changes: 12 additions & 1 deletion api/middleware/gzip.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
package middleware

import (
"strings"

"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)

// GZIP is ready-to-go GZIP middleware based on echo middleware
var GZIP = middleware.GzipWithConfig(middleware.GzipConfig{Level: 5})
// GZIP is ready-to-go GZIP middleware with a skipper to exclude certain routes
var GZIP = middleware.GzipWithConfig(middleware.GzipConfig{
Level: 5,
Skipper: func(c echo.Context) bool {
// Skip GZIP compression for routes starting with /features
// as compression messes with pg_featureserv
return strings.Contains(c.Request().URL.Path, "/features")
},
})
17 changes: 14 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,28 @@ services:
condition: service_started
# --------------------------------------
featureserv:
image: pramsey/pg_featureserv
build:
context: pg_featureserv
container_name: featureserv
restart: always
environment:
- DATABASE_URL=postgres://cumulus_user:cumulus_pass@cumulusdb:5432/postgres
# - DATABASE_URL=postgres://cumulus_user:cumulus_pass@cumulusdb:5432/postgres
# Individual PG env vars are easier to provide in IaC instead of the DATABASE_URL
- PGHOST=cumulusdb
- PGPORT=5432
- PGUSER=cumulus_user
- PGPASSWORD=cumulus_pass
- PGDATABASE=postgres
- PGFS_SERVER_HTTPPORT=8080
- PGFS_SERVER_HTTPSPORT=8443
- PGFS_SERVER_URLBASE=http://localhost/features
- PGFS_SERVER_BASEPATH=/features
- PGFS_SERVER_DEBUG=true
- PGFS_WEBSITE_BASEMAPURL=http://a.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png
- PGFS_WEBSITE_BASEMAPURL=http://a.tile.openstreetmap.org/{z}/{x}/{y}.png
# The API provides a proxy using /features
# This port exposure is for direct access/troubleshooting locally
ports:
- "8080:8080"
depends_on:
cumulusdb:
condition: service_started
Expand Down
10 changes: 10 additions & 0 deletions pg_featureserv/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM pramsey/pg_featureserv:20241119

# Copy your entrypoint script into the container
COPY entrypoint.sh /entrypoint.sh

# Set the entrypoint
ENTRYPOINT ["/entrypoint.sh"]

# Default command of pg_featureserv
CMD ["./pg_featureserv"]
10 changes: 10 additions & 0 deletions pg_featureserv/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

# Construct the DATABASE_URL using environment variables
export DATABASE_URL="postgresql://${PGUSER}:${PGPASSWORD}@${PGHOST}/${PGDATABASE}"

# Debug - DO NOT enable this and commit, we don't want it in the AWS logs)
# echo "DATABASE_URL is: $DATABASE_URL"

# Now, execute the default command (pg_featureserv or any other service)
exec "$@"

0 comments on commit 9d72451

Please sign in to comment.