Skip to content

Commit

Permalink
feature(caddy-pmtiles): add Caddyfile
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonStuff committed Nov 11, 2024
1 parent f10675d commit ceabfcf
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
# to use handle_path for prefixes, pmtiles_proxy must have a defined
# position in the ordering of handlers.
order pmtiles_proxy before reverse_proxy
email ${MAPS_EMAIL}
}

${MAPS_DOMAIN} {
handle_path /tiles/* {
pmtiles_proxy {
bucket ${MAPS_PMTILES_LOCATION}
cache_size 19000
# used to embed a tiles URL in TileJSON.
public_url https://${MAPS_DOMAIN}/tiles
}
}
}
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@ RUN xcaddy build --with github.com/caddy-dns/cloudflare --with github.com/protom

FROM caddy:2.8.4

# Install envsubst
RUN apk update && apk add gettext && rm -rf /var/cache/apk/*

COPY --from=builder /usr/bin/caddy /usr/bin/caddy
COPY Caddyfile /etc/caddy/Caddyfile.template
COPY entrypoint.sh /entrypoint.sh

RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
20 changes: 20 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
set -e

# Debug: print environment variables
echo "Environment variables:"
echo "MAPS_DOMAIN=${MAPS_DOMAIN}"
echo "MAPS_PMTILES_LOCATION=${MAPS_PMTILES_LOCATION}"
echo "MAPS_EMAIL=${MAPS_EMAIL}"

# Replace environment variables in Caddyfile
export MAPS_DOMAIN
export MAPS_PMTILES_LOCATION
export MAPS_EMAIL
envsubst '${MAPS_DOMAIN} ${MAPS_PMTILES_LOCATION} ${MAPS_EMAIL}' < /etc/caddy/Caddyfile.template > /etc/caddy/Caddyfile

echo "Caddyfile:"
cat /etc/caddy/Caddyfile

# Execute Caddy
exec /usr/bin/caddy run --config /etc/caddy/Caddyfile

0 comments on commit ceabfcf

Please sign in to comment.