Skip to content

Commit

Permalink
Merge pull request #68 from soundscape-community/rdservice
Browse files Browse the repository at this point in the history
data service: Add simple blue/green deployment to docker-compose.yml, add Caddyfiles to git
  • Loading branch information
steinbro authored Nov 9, 2023
2 parents 5e124af + 9cfa144 commit 72841ff
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 4 deletions.
26 changes: 26 additions & 0 deletions svcs/data/caddy/Caddyfile.blue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Caddy configuration file for Soundscape back-end services

# There are two Caddy configuration files that should be placed in /etc/caddy on
# the server. A symbolic link /etc/caddy/Caddyfile points to the current active
# configuration. The only difference between the two configurations is the port
# number to forward the request to, 8081 for blue and 8082 for green.

tiles.soundscape.services {
reverse_proxy localhost:8081 {
header_up X-Real-IP {remote_host}
}
header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
}

newprod0.openscape.io {
reverse_proxy localhost:8081 {
header_up X-Real-IP {remote_host}
}
header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
}

share.soundscape.services {
header /.well-known/apple-app-site-association Content-Type application/json
root * /home/soundscape/share.soundscape.services/
file_server
}
26 changes: 26 additions & 0 deletions svcs/data/caddy/Caddyfile.green
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Caddy configuration file for Soundscape back-end services

# There are two Caddy configuration files that should be placed in /etc/caddy on
# the server. A symbolic link /etc/caddy/Caddyfile points to the current active
# configuration. The only difference between the two configurations is the port
# number to forward the request to, 8081 for blue and 8082 for green.

tiles.soundscape.services {
reverse_proxy localhost:8082 {
header_up X-Real-IP {remote_host}
}
header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
}

newprod0.openscape.io {
reverse_proxy localhost:8082 {
header_up X-Real-IP {remote_host}
}
header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
}

share.soundscape.services {
header /.well-known/apple-app-site-association Content-Type application/json
root * /home/soundscape/share.soundscape.services/
file_server
}
37 changes: 33 additions & 4 deletions svcs/data/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,25 @@
#
# Once all three components are running (PostGIS server, ingest service, tile
# server), test by fetching a tile in your browser, e.g.:
# http://localhost:8080/16/18745/25070.json
# http://localhost:8081/16/18745/25070.json
#
# Helpful tool for finding other tile coordinates (the last two numbers in the
# above URL): http://bboxfinder.com/

# There are two tilesrv services defined, tilesrv-blue and tilesrv-green to
# allow for updates without downtime. tilesrv-blue is started by default.
#
# To update:
# docker compose up --build -d tilesrv-green
# Test tilesrv-green on localhost:8082
# switch Caddy config:
# sudo ln -s /etc/caddy/Caddyfile.green /etc/caddy/Caddyfile
# sudo systemctl reload caddy
# if everything works, bring down tilesrv-blue:
# docker compose stop tilesrv-blue
# docker compose rm tilesrv-blue
#
# For the next update swap blue and green in the instructions above.
version: '3.8'

volumes:
Expand Down Expand Up @@ -55,14 +70,28 @@ services:
postgis:
condition: service_healthy

tilesrv:
tilesrv-blue:
image: soundscape/tilesrv
build:
dockerfile: Dockerfile.tilesrv
environment:
- DSN=host=postgis port=5432 dbname=osm user=postgres password=secret
ports:
- "127.0.0.1:8081:8080"
depends_on:
postgis:
condition: service_healthy

tilesrv-green:
image: soundscape/tilesrv
build:
dockerfile: Dockerfile.tilesrv
environment:
- DSN=host=postgis port=5432 dbname=osm user=postgres password=secret
ports:
- "8080:8080"
- "127.0.0.1:8082:8080"
depends_on:
postgis:
condition: service_healthy
condition: service_healthy
# prevent tilesrv-green from starting automatically
profiles: ["tilesrv-green"]

0 comments on commit 72841ff

Please sign in to comment.