@@ -6,9 +6,13 @@ near-zero downtime and easy rollback.
66
77## 1. Adjust the Compose file
88
9- Remove the Caddy ` ports: ` section in ` compose.yaml ` . We'll no longer expose
10- ports in the stacks – instead a simple "front proxy" will expose ports and
11- proxy to the active stack.
9+ ### Remove exposed ports
10+
11+ We'll no longer expose ports in the stacks, instead a simple "front proxy" will
12+ sit in front of the two stacks, exposing ports and proxying to the active
13+ stack. So remove the Caddy service's ` ports: ` section in ` compose.yaml ` .
14+
15+ ### Serve http-only in the stacks
1216
1317Set ` CADDY_SITE_ADDRESS ` to only ` :80 ` (leaving TLS termination to the front
1418proxy):
1923 CADDY_SITE_ADDRESS : :80
2024` ` `
2125
26+ ### Share volumes between the stacks
27+
2228To share data between the two stacks (database, uploads, etc.), give volumes
2329explicit names:
2430
@@ -30,20 +36,31 @@ volumes:
3036 name : user-data
3137` ` `
3238
33- ## 2. Bring up both Stacks
39+ ### Make the networks external
3440
35- ` ` ` sh
36- scp compose.yaml youruser@yourserver:blue/compose.yaml
37- scp compose.yaml youruser@yourserver:green/compose.yaml
41+ The front proxy needs to connect to both ` blue_default` and `green_default`
42+ networks. This makes it easier to start the front proxy regardless of whether
43+ the stacks are up :
44+
45+ ` ` ` yaml title="compose.yaml"
46+ networks:
47+ default:
48+ external: true
49+ ` ` `
50+
51+ In the override file, don't use external networks :
52+
53+ ` ` ` yaml title="compose.override.yaml"
54+ networks:
55+ default:
56+ external: false
3857` ` `
3958
40- On the server:
59+ Shell into the server and manually create the two networks :
4160
4261` ` ` sh
43- cd blue
44- docker compose up -d
45- cd ../green
46- docker compose up -d
62+ docker network create blue_default
63+ docker network create green_default
4764` ` `
4865
4966# # 3. Add a Front Proxy
@@ -80,13 +97,13 @@ docker run -d \
8097 caddy:2
8198` ` `
8299
83- ## 4. Upgrading
100+ # # 4. Deploying/ Upgrading
84101
85102Deploying is the same as [before](deploying.md), but now we're deploying the
86103_idle stack_. For this example, `green` is idle so that's the one we're
87104deploying.
88105
89- Create ` blue ` and ` green ` directories on the server and deploy ` compose.yaml `
106+ Create `blue` and `green` directories on the server and copy `compose.yaml`
90107into the idle stack's directory :
91108
92109` ` ` sh
0 commit comments